-2

for example the program should be able to execute this task.

21.34 should be displayed as 21.35, 21.32 should be displayed as 21.30, 21.36 should be displayed as 21.35, 21.38 should be displayed as 21.40

please explain or give me code samples on how to make this work. or is it even possible? Thanks!

Kyler
  • 3
  • 2

1 Answers1

-1

If you want to round a double to the nearest multiple of 0.05 you can do

d = Math.round(d * 20) / 20.0;

In countries like Australia you need to round to a multiple of 5c.

please explain

As you are asking the question, you really need to be able to explain it.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130