Created
April 29, 2025 17:22
-
-
Save openm1ke/7d17dfe3dc7f2cfc46ecab30fe8fffa8 to your computer and use it in GitHub Desktop.
Копейка рубль бережёт
This file contains hidden or 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 ConvertKopeikiToRublesTest { | |
| public static void main(String[] args) { | |
| long kopecks = 1; | |
| double totalRubles = 0.0; | |
| for (int i = 0; i < 2_000_000_000; i++) { | |
| totalRubles += kopecks / 100.0; | |
| } | |
| double expectedRubles = 2_000_000_000 / 100.0; | |
| System.out.printf("Ожидание: %.2f%n", expectedRubles); | |
| System.out.printf("Реальность: %.2f%n", totalRubles); | |
| double difference = Math.abs(expectedRubles - totalRubles); | |
| System.out.printf("В копилку: %.15f%n", difference); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment