Created
July 12, 2020 15:05
-
-
Save antic183/d3852ab4fcd4ad579c6328e107f5d32d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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