Skip to content

Instantly share code, notes, and snippets.

@openm1ke
Created April 29, 2025 17:22
Show Gist options
  • Select an option

  • Save openm1ke/7d17dfe3dc7f2cfc46ecab30fe8fffa8 to your computer and use it in GitHub Desktop.

Select an option

Save openm1ke/7d17dfe3dc7f2cfc46ecab30fe8fffa8 to your computer and use it in GitHub Desktop.
Копейка рубль бережёт
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