MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / ulp

Method ulp

CodenameOne/src/com/codename1/util/MathUtil.java:1292–1316  ·  view source on GitHub ↗
(double d)

Source from the content-addressed store, hash-verified

1290 ///
1291 /// size of an ulp for the argument
1292 public static double ulp(double d) {
1293 if (Double.isNaN(d)) {
1294 // If the argument is NaN, then the result is NaN.
1295 return Double.NaN;
1296 }
1297
1298 if (Double.isInfinite(d)) {
1299 // If the argument is positive or negative infinity, then the
1300 // result is positive infinity.
1301 return Double.POSITIVE_INFINITY;
1302 }
1303
1304 if (d == 0.0) {
1305 // If the argument is positive or negative zero, then the result is Double.MIN_VALUE.
1306 return Double.MIN_VALUE;
1307 }
1308
1309 d = Math.abs(d);
1310 if (d == Double.MAX_VALUE) {
1311 // If the argument is Double.MAX_VALUE, then the result is equal to 2^971.
1312 return MAX_ULP;
1313 }
1314
1315 return nextAfter(d, Double.MAX_VALUE) - d;
1316 }
1317
1318 private static boolean isSameSign(double x, double y) {
1319 return copySign(x, y) == x;

Callers 1

invokeStatic7Method · 0.45

Calls 4

isNaNMethod · 0.95
isInfiniteMethod · 0.95
absMethod · 0.95
nextAfterMethod · 0.95

Tested by

no test coverage detected