Java Onlines
Java Sandbox
Java Benchmark
Math
String
Python Sandbox
PHP Sandbox
Java Sandbox
Java Benchmark
Math
String
Python Sandbox
PHP Sandbox
Online Java ulp() function
ulp
- Returns the size of the unit of least precision (ulp) of x
Title
public class Main { public static void main(String[] args) { double a = 8.1; // Input positive double value, Output ulp(a) System.out.println(Math.ulp(a)); double b = -37.1; // Input negative double value, Output ulp(-a)==ulp(a) System.out.println(Math.ulp(b)); float c = -1.0f / 0; // Input negative infinity, Output positive infinity System.out.println(Math.ulp(c)); double d = 0.0; // Input zero, Output Double.MIN_VALUE System.out.println(Math.ulp(d)); double e = Double.MAX_VALUE ; // Input Double.MAX_VALUE, Output 2 power of 971 System.out.println(Math.ulp(e)); float f = Float.MAX_VALUE ; // Input Float.MAX_VALUE, Output 2 power of 104 System.out.println(Math.ulp(f)); } }
Run on Java version:
14
14.0.1
14
13
13.0.2
13.0.1
13
12
12.0.2
12.0.1
12
11
11.0.7
11.0.6
11.0.5
11.0.4
11.0.3
11.0.2
11.0.1
11
10
10.0.2
10.0.1
10
9
9.0.4
9.0.1
9
8
8
7
7
6
6
Execute Code
Math Functions
abs
acos
asin
atan
atan2
cbrt
ceil
copySign
cos
cosh
exp
expm1
floor
getExponent
hypot
IEEEremainder
log
log10
log1p
max
min
nextAfter
nextUp
pow
random
rint
round
signum
sin
sinh
sqrt
tan
tanh
toDegrees
toRadians
ulp