1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Update java-basic-questions-01.md

printf 可以复现注释后的小数点数据
This commit is contained in:
Kisa-Dong 2024-10-25 11:14:12 +08:00 committed by GitHub
parent 8adefc8b20
commit aa8309167f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -665,7 +665,7 @@ private static long sum() {
```java ```java
float a = 2.0f - 1.9f; float a = 2.0f - 1.9f;
float b = 1.8f - 1.7f; float b = 1.8f - 1.7f;
System.out.println(a);// 0.100000024 System.out.printf("%.9f",a);// 0.100000024
System.out.println(b);// 0.099999905 System.out.println(b);// 0.099999905
System.out.println(a == b);// false System.out.println(a == b);// false
``` ```