问题描述:

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!

相关阅读:
Top