Skip to content

Instantly share code, notes, and snippets.

@antic183
Created July 12, 2020 15:05
Show Gist options
  • Save antic183/d3852ab4fcd4ad579c6328e107f5d32d to your computer and use it in GitHub Desktop.
Save antic183/d3852ab4fcd4ad579c6328e107f5d32d to your computer and use it in GitHub Desktop.
public class FloatingPointProblem {
public static void main(String []args) {
float f = 3.1f;
double d = 3.1;
System.out.println(Float.floatToRawIntBits(f) + "\n"); // 1078355558
System.out.println(Double.doubleToRawLongBits(d) + "\n"); //4614162998222441677
if (d == f) {
System.out.println("f == d");
} else {
System.out.println("f != d");
}
// output f != d
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment