其值不能被重新$ P $由双正确psented [英] Which values cannot be represented correctly by a double

查看:166
本文介绍了其值不能被重新$ P $由双正确psented的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

双数据类型不能正确地重新present一些基本的10个值。这是因为重present实数如何浮点数。这意味着是重新presenting货币价值时,应该使用十进制值类型为prevent错误。 (随时纠正这一preamble错误)

The Double data type cannot correctly represent some base 10 values. This is because of how floating point numbers represent real numbers. What this means is that when representing monetary values, one should use the decimal value type to prevent errors. (feel free to correct errors in this preamble)

我想知道的是什么是其中present下双数据类型这样的问题,在64位架构的值在标准Net框架(C#,如果有差别)?

What I want to know is what are the values which present such a problem under the Double data-type under a 64 bit architecture in the standard .Net framework (C# if that makes a difference) ?

我希望答案是一个公式或规则来找到这样的价值观,但我也想了一些示例值。

I expect the answer the be a formula or rule to find such values but I would also like some example values.

推荐答案

任何不能写成2正面和负面的权力,也不可能完全重新psented为二进制浮点数$ P $的款项数目。

Any number which cannot be written as the sum of positive and negative powers of 2 cannot be exactly represented as a binary floating-point number.

常见 IEEE格式浮动 32位和64位重presentations -point号施加更多的限制;它们限制的二进制两个有效位和指数位数。因此,有最大值和最小值再presentable号(约+/- 10 ^ 308(基数为10),如果没有记错),并限制了一些可以重新presented的precision。此限制在precision意味着,对于64位数字,的2的最大功率和最小功率在多个指数之间的差异限制为52,因此,如果你的电话号码包括在2一个术语^ 52不能还包括了一个期限2 ^ -1。

The common IEEE formats for 32- and 64-bit representations of floating-point numbers impose further constraints; they limit the number of binary digits in both the significand and the exponent. So there are maximum and minimum representable numbers (approximately +/- 10^308 (base-10) if memory serves) and limits to the precision of a number that can be represented. This limit on the precision means that, for 64-bit numbers, the difference between the exponent of the largest power of 2 and the smallest power in a number is limited to 52, so if your number includes a term in 2^52 it can't also include a term in 2^-1.

这不可能完全重新psented二进制浮点数字$ P $的数字简单的例子包括 1/3 2/3 1/5 10 ^ 5000

Simple examples of numbers which cannot be exactly represented in binary floating-point numbers include 1/3, 2/3, 1/5, 10^5000.

由于集浮点数的(在任何重新presentation)是有限的,并且实数集的是无限的,一种算法找到该不完全重新presentable作为一个实数浮点数是随机选择的实数。真正的数字是完全重新presentable作为一个浮点数的概率是 0

Since the set of floating-point numbers (in any representation) is finite, and the set of real numbers is infinite, one algorithm to find a real number which is not exactly representable as a floating-point number is to select a real number at random. The probability that the real number is exactly representable as a floating-point number is 0.

这篇关于其值不能被重新$ P $由双正确psented的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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