Java和C#双打之间的区别 [英] Difference between java and C# doubles
问题描述
double
是一种表示Java中64位IEEE 754浮点数的类型
double
is a type that represents 64-bit IEEE 754 floating-point number in Java
double
是一种以C#表示IEEE 754格式的64位双精度数字的类型.
double
is a type that represents 64-bit double-precision number in IEEE 754 format in C#.
两种语言都遵循相同的规范.那么为什么下面的代码有区别呢?我也检查了Mono.
Both languages follow the same specification. So why there is difference in following code? I checked Mono as well.
Double.MIN_VALUE == (Double.MIN_VALUE + 1.0); // false
Console.WriteLine(Double.MinValue == (Double.MinValue + 1.0)); // true
推荐答案
Java的Double.MIN_VALUE
是2^-1074
同时
C#的Double.MinValue
是-1.7976931348623157E+308
它们具有不同的值,因为它们遵循不同的语义.
They have different values because they follow a different semantic.
一个常量,该常量持有double类型的最小正非零值
A constant holding the smallest positive nonzero value of type double
在C#中:
代表Double的最小可能值.此常数的值为负1.7976931348623157E + 308
Represents the smallest possible value of a Double [...] The value of this constant is negative 1.7976931348623157E+308
这篇关于Java和C#双打之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!