你如何确定在32位IEEE浮点值中的集合S中有多少个整数 [英] How do you determine how many integers are in set S of all in 32-bit IEEE floating-point values

查看:333
本文介绍了你如何确定在32位IEEE浮点值中的集合S中有多少个整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以向我解释它到底是什么?我知道这基本上意味着它是单精度的1bit符号,8bit指数和23bit尾数。答案不应该只是2 * 2 ^ 8-2 * 2 ^ 23?b / b
$ b编辑:确定2 * 2 ^ 8-2 * 2 ^ 23确定所有32位IEEE浮点值

解决方案

有限正浮点数的范围从2 <-149 < (最小的次正规)到2 128 128 -2 104(有限值的指数最大的数和所有位的有效数)。我们可以将它们分为三类:


  • 小于1的值。其中的零是整数。

  • 数值从1到2 <24> -1。其中有些是整数,有些则不是。但是,此范围内的每个整数都在浮点数组中,因为它们至多有24个有效位,因此可用24位有效数表示。因此,浮点数在这个区间内有2个24 <-1>整数。
  • 从2 24 和up的值。所有这些都是整数,因为它们的有效位置中最不重要的位置至少为1.此范围包含从24到127和每个允许的有效位的指数(二)的所有浮点数。有效数字是以1开头,后面跟着23位数字,所以有2个23个有效数字。因此,这些数字有(127-24 + 1)•2 23


    对于正整数是0 + 2 24 -1 +(127-24 + 1)* 2 23。负数的数量是一样的,0增加了一个,所以总数是1,778,384,895。

    (一旦我们找到了这个数字,它给了我们一个搜索键找到重复的问题。)


    Could anybody explain to me what it is stating exactly? I know this basically means that it's single precision with 1bit sign, 8bit exponents and 23bit mantissa. Shouldn't the answer is just be 2 * 2^8-2 * 2^23?

    Edit:does 2 * 2^8-2 * 2^23 determine all 32-bit IEEE floating-point values

    解决方案

    The finite positive floating-point numbers range from 2-149 (the smallest subnormal) to 2128-2104 (the number with the largest exponent for finite values and a significand of all one bits). We can group them into three categories:

    • The values less than 1. Zero of these are integers.
    • The values from 1 to 224-1. Some of these are integers, and some are not. However, every integer in this range is in the set of floating-point numbers, because they have at most 24 significant bits and are therefore representable with 24-bit significands. Therefore, the floating-point numbers have 224-1 integers in this interval.
    • The values from 224 and up. All of these are integers, because the least significant position in their significands represents at least 1. This range contains all floating point numbers with exponents (of two) from 24 to 127 and every allowed significand. The significands are all those starting with "1." and followed by any 23 bits, so there are 223 significands. Therefore, there are (127-24+1)•223 of these numbers.

    The total for positive integers is 0 + 224-1 + (127-24+1)*223. The number of negative integers is the same, and 0 adds one more, so the grand total is 1,778,384,895.

    (Once we have found that number, it gives us a search key to find duplicate questions.)

    这篇关于你如何确定在32位IEEE浮点值中的集合S中有多少个整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆