This should work for an arbitrary mantissa. Just add the offset to the next integer to your value and round down.
The rounding is done by floor. Here is what the java API says to floor:
Returns the largest (closest to positive infinity) double value that
is less than or equal to the argument and is equal to a mathematical
integer.
This solution is similar to the one from @Thomas Stets, but imho it is easier to understand since rounding is done in only one direction.
Math.floor(x+0.7)
should do it.This should work for an arbitrary mantissa. Just add the offset to the next integer to your value and round down. The rounding is done by floor. Here is what the java API says to floor:
This solution is similar to the one from @Thomas Stets, but imho it is easier to understand since rounding is done in only one direction.