双或浮 [英] double or float

查看:72
本文介绍了双或浮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




只是一个普遍的问题。

对于大值,哪种数据类型更精确:

浮动或双倍?


谢谢。

克里斯

Hi,

just a general question.
Which data type is more precise for large values:
float or double?

Thank you.
Chris

推荐答案

Christian Christmann写道:
Christian Christmann wrote:
只是一个普遍的问题。
哪个数据类型对于大值更精确:
浮点数还是双倍?
just a general question.
Which data type is more precise for large values:
float or double?




通常,''double''包含更多_significant_digits_,因此,作为

a一般情况,''double''对于* any *值更精确。

另外通常,''double''的范围更广。


V



Usually, ''double'' contains more _significant_digits_, so, as
a general case, ''double'' is more precise for *any* values.
Also, usually, ''double'' has a wider range.

V


Christian Christmann写道:
Christian Christmann wrote:


只是一个普遍的问题。
哪个数据类型对于大值更精确:
浮点数还是双倍?
Hi,

just a general question.
Which data type is more precise for large values:
float or double?




定义大和价值。如果你的意思是整数值,那么

整数更精确,假设它可以保持该值。你的编译器

可能支持64位整数,它们的范围相当大。


如果你需要浮点计算或者数字太过

对于整数类型大,使用浮点类型。 float,

double和long double的大小是实现定义的,但它保证:


sizeof (float)< = sizeof(double)< = sizeof(long double)


更多位通常等于更精确,但它取决于位数

被分配(即浮点格式是什么)。有关浮点算术的详细信息,请参阅每个计算机科学家应该具备的内容。
了解浮点算术

http://docs.sun.com/source/806-3568 /ncg_goldberg.html)


干杯! --M



Define "large" and "values". If you mean integral values, then an
integer is more precise, assuming it can hold the value. Your compiler
may support 64-bit integers, which hold a fairly vast range.

If you require floating point computations or if the numbers are too
large for integral types, use floating point types. The sizes of float,
double, and long double are implementation-defined, but it is
guaranteed that:

sizeof(float) <= sizeof(double) <= sizeof(long double)

More bits generally equals more precision, but it depends how the bits
are allocated (i.e. what the floating-point format is). For more info
on floating point arithmetic, see "What Every Computer Scientist Should
Know About Floating-Point Arithmetic"
(http://docs.sun.com/source/806-3568/ncg_goldberg.html).

Cheers! --M


Christian Christmann写道:
Christian Christmann wrote:
只是一般性问题。
哪种数据类型对于大值更精确:
浮点数还是双倍?
Just a general question.
Which data type is more precise for large values:
float or double?




double



double


这篇关于双或浮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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