0

i try to calculate whether the single dosages of a therapy are in accordance with the total dosage.

I created a little java tool.

For this i included a small check:

System.out.println(total);
System.out.println(single);
System.out.println(total % single);
if(total % single == 0.0) {
System.out.println("test");
}

Now. Here are a coule of results for some of my data points. And i just dont understand it:

Two examples where it works as intended.

Total: 60
Single: 7.5
Result: 0.0

Total: 30.0
Single: 3.0
Result: 0.0

Modulo gives out wrong results? Shouldnt it also be 0.0?

Total: 37.0
Single: 3.7
Result: 3.6999999999999984

Any explanations for this?

Donselm
  • 77
  • 1
  • 8

0 Answers0