In Java, when a long value is cast to double value, the IEEE754 round-to-nearest rounding mode is applied when lossless conversion is not possible.
For example, cast from 1L << 55 or (1L << 55) + 8 to double are lossless. However, any number in between cannot be accurately represented as double. The IEEE-754 round-to-nearest (ties to even) rounding mode is applied by default. As a result, (1L << 55) + 4) or below will round down where as (1L << 55) + 5 or up will round up.
Is there any function in standard library or guava that allows me to cast a long to a double using Round toward +∞ or Round toward -∞ mode (chosen on a per-callsite basis)? Assuming there isn't one, how do I write such two functions myself efficiently?