Divrem maximum precision for the remain

I think I see the misunderstanding here. divrem does integer flooring division (div), and also returns the remainder of the operation (the same remainder as in long division). rem is not the the fractional part of a floating point number (some languages have a function called frac that extracts this).

This is the expected behavior of divrem:

julia> divrem(1000, 17)
(58, 14)

julia> 58 + 14/17
58.8235294117647

julia> 1000/17
58.8235294117647

The 14 returned by rem is the remainder after long division by 17, so 14/17 is the fractional part.

I think you were expecting this?

julia> divrem(1000/17, 1)
(58.0, 0.823529411764703)

julia> 1000/17
58.8235294117647
1 Like