Returns the argument's ulp (unit in the last place). The size of a ulp of a double value is the positive distance between this value and the double value next larger in magnitude. For non-NaN x, ulp(-x) == ulp(x). Special cases: ulp(+0.0) = Double.MIN_VALUE
(double d)
| 997 | * @return the size of a ulp of the argument. |
| 998 | */ |
| 999 | public static double ulp(double d) { |
| 1000 | // special cases |
| 1001 | if (Double.isInfinite(d)) { |
| 1002 | return Double.POSITIVE_INFINITY; |
| 1003 | } else if (d == Double.MAX_VALUE || d == -Double.MAX_VALUE) { |
| 1004 | return pow(2, 971); |
| 1005 | } |
| 1006 | d = Math.abs(d); |
| 1007 | return nextafter(d, Double.MAX_VALUE) - d; |
| 1008 | } |
| 1009 | |
| 1010 | /** |
| 1011 | * Returns the argument's ulp (unit in the last place). The size of a ulp of |
nothing calls this directly
no test coverage detected