Skip to content

Instantly share code, notes, and snippets.

@mepcotterell
Last active February 17, 2020 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mepcotterell/547174eca1dd52b8ffa6f148e669c174 to your computer and use it in GitHub Desktop.
Save mepcotterell/547174eca1dd52b8ffa6f148e669c174 to your computer and use it in GitHub Desktop.

Unit of Least Precision (ULP) in Java

Double

double ulp1 = Math.ulp(1.0);
double ulp1 = Double.longBitsToDouble(971l << 52);
double ulp1 = 2.220446049250313E-16;

Float

float ulp1 = Math.ulp(1.0f);
float ulp1 = Float.intBitsToFloat(104 << 23);
float ulp1 = 1.1920929E-7;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment