Incorrect result from `floor` function

The issue here is that Float64 only has 53 mantissa bits, so not every Int can be represented exactly. d/9 converts d to a Float64, which involves some rounding:

julia> d = 37889062372043916
37889062372043916

julia> Float64(d)
3.788906237204392e16

julia> Int(ans)
37889062372043920

The documentation of floor is not actually the issue here, since the rounding is introduced by the conversion from Int to Float64, not floor.

5 Likes