IEEE 754实数可以“覆盖"吗?其范围内的所有整数? [英] Can a IEEE 754 real number "cover" all integers within its range?

查看:103
本文介绍了IEEE 754实数可以“覆盖"吗?其范围内的所有整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对原始问题进行了编辑(缩短),以解决精度问题,而不是范围问题.

单精度或双精度,实数的每种表示形式都限于(-range,+ range).在此范围内的是一些整数(1、2、3、4 ...,依此类推;负数也是如此).

Single, or double precision, every representation of real number is limited to (-range,+range). Within this range lie some integer numbers (1, 2, 3, 4..., and so on; the same goes with negative numbers).

是否可以保证IEEE 754实数(浮点数,双精度数等)可以覆盖"其范围内的所有个整数? 覆盖"是指实数将精确地表示整数,而不是(例如)"5.000001".

Is there a guarantee that a IEEE 754 real number (float, double, etc) can "cover" all integers within its range? By "cover" I mean the real number will represent the integer number exactly, not as (for example) "5.000001".

提醒一下: http://www3 .ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html 很好地解释了各种数字表示格式.

Just as reminder: http://www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html nice explanation of various number representation formats.

更新:

因为问题是可以",所以我也在寻找无法做到这一点的事实-因为它引用一个数字就足够了.例如不行,例如,编号1748574不能完全用浮点数表示"(当然,这个数字是凭空产生的.)

Because the question is for "can" I am also looking for the fact this cannot be done -- for it quoting a number is enough. For example "no it cannot be done, for example number 1748574 is not represented exactly by float number" (this number is taken out of thin air of course).

好奇的读者

如果您想使用IEEE 754表示法-在线计算器: http://www.ajdesigner.com/fl_ieee_754_word/ieee_32_bit_word.php

If you would like to play with IEEE 754 representation -- on-line calculator: http://www.ajdesigner.com/fl_ieee_754_word/ieee_32_bit_word.php

推荐答案

macias,要添加到phant0m已经很好的答案中(赞成;我建议您接受),我将使用您自己的话.

macias, to add to the already excellent answer by phant0m (upvoted; I suggest you accept it), I'll use your own words.

不行,例如,数字16777217不能用浮点数精确表示."

"No it cannot be done, for example number 16777217 is not represented exactly by float number."

此外,例如数字922337203685477575809不能完全用双精度数字表示".

Also, "for example number 9223372036854775809 is not represented exactly by double number".

这是假设您的计算机使用的是IEEE浮点格式,这是一个不错的选择.

This is assuming your computer is using the IEEE floating point format, which is a pretty strong bet.

这篇关于IEEE 754实数可以“覆盖"吗?其范围内的所有整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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