double的范围是否比long更大? [英] Does double have a greater range than long?

查看:214
本文介绍了double的范围是否比long更大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MSDN上的一篇文章中,它指出 double 数据类型的范围为"-1.79769313486232e308 .. 1.79769313486232e308".而 long 数据类型的范围仅为"-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807".如果 double 的大小均为64位,那么如何容纳比 long 长的数据呢?

In an article on MSDN, it states that the double data type has a range of "-1.79769313486232e308 .. 1.79769313486232e308". Whereas the long data type only has a range of "-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807". How can a double hold so much more data than a long if they are both 64 bits in size?

http://msdn.microsoft.com/en-us/library/cs7y5x0x(v=vs.90).aspx

推荐答案

可能加倍的数量和可能的多头数量相同,只是分配方式不同*.

The number of possible doubles, and the number of possible longs is the same, they are just distributed differently*.

多头是均匀分布的,而浮动则不是.您可以在此处了解更多信息.

The longs are uniformly distributed, while the floats are not. You can Read more here.

我会写更多,但由于某种原因,光标会在手机上的各处跳来跳去.

I'd write more, but for some reason the cursor is jumping around all over the place on my phone.

这实际上可能更有用: http://zh-CN.wikipedia.org/wiki/Double-precision_floating-point_format#section_1

This might actually be more helpful: http://en.wikipedia.org/wiki/Double-precision_floating-point_format#section_1

Edit2:甚至更好: http://blogs.msdn.com/b/dwayneneed/archive/2010/05/07/fun-with-floating-point.aspx

and this is even better: http://blogs.msdn.com/b/dwayneneed/archive/2010/05/07/fun-with-floating-point.aspx

* 根据该链接,实际上似乎有更多的long,因为由于NaN和其他特殊数字的表示方式,一些双精度数丢失了.

这篇关于double的范围是否比long更大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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