最大值与长尺寸和双在.NET [英] Maximum value vs. size of long and double in .NET

查看:164
本文介绍了最大值与长尺寸和双在.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据了解,在双方长期.NET尺寸和双8个字节。然而,双可存储显著数量大于长。这怎么可能,考虑到双也需要小数点后存储在数字数据?

It's known that in .NET size of both long and double is 8 bytes. However, double can store significantly larger number than long. How can it be, considering that double also needs to store data on digits after decimal point?

这个问题较短的版本:

Math.Pow(2,64)== long.MaxValue Math.Pow(2,64)&其中; double.MaxValue

Math.Pow(2, 64) == long.MaxValue Math.Pow(2, 64) < double.MaxValue

推荐答案

简答题双只保存最显著的数字,而不是所有的,可能是在数位。例如如果你有长也不会被存储小数点或任何该图只是为了deciaml点左侧后的任何信息的数字的一个双>最大值

Short answer double only stores the most significant figure and not all the digits that could be in the number. e.g. if you have a double > max value of long it will not be storing any information for digits after the decimal point or any of the figure just to the left of the deciaml point.

对于所有的详情,请参阅什么每台计算机科学家应该知道浮点运算

For all details see What every computer scientist should know about Floating-Point Arithmetic

这篇关于最大值与长尺寸和双在.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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