|
|
|
|
|
by dwheeler
2490 days ago
|
|
I just tried this on Python3 on a 64-bit x86 system: import math
x = 0.49999999999999994
print(x-0.5)
print(math.floor(x+0.5))
I got these printouts: -5.551115123125783e-17
1
So yes, something less than 1/2, with 1/2 added to it, has a floor of 1 in floating point math.Yet another reminder that floating point calculations are approximations, and not exact. |
|
1.0
280.594 ns (6 allocations: 336 bytes)0.0