当前位置: 动力学知识库 > 问答 > 编程问答 >

variable assignment - double datatype is not assigning large value

问题描述:

I am trying to assign a large value to a double datatype for example

double someValue = 36028797018963967D;

but the problem is, when I debug the value of variable someValue, it becomes 36028797018963968D and I cant figure out why.

Any help will be appreciated,

Thanks!

网友答案:

Both of these numbers are the same in 64 bit floating point. What gets printed is an artifact of the method used to print them. Try this:

assert(36028797018963967D == 36028797018963968D)

It works!

分享给朋友:
您可能感兴趣的文章:
随机阅读: