[Numpy-discussion] Rounding to next lowest float
Tue Oct 11 13:00:31 CDT 2011
Can anyone think of a clever way to round an integer to the next
lowest integer represented in a particular floating point format?
In : a = 2**25+3
This is out of range of the continuous integers representable by float32, hence:
In : print a, int(np.float32(a))
But I want to round down (floor) the integer in float32. That is, in
this case I want:
>>> floor_exact(a, np.float32)
I can break the float into its parts to do it:
but that's obviously rather ugly... Is there a simpler way? I'm sure
there is and I haven't thought of it...
More information about the NumPy-Discussion