1

I need to round a decimal to the next quarter for example:

0.21 to 0.25
0.42 to 0.5
0.63 to 0.75
0.90 to 1

Thanks in advance for any help.

Jamiec
  • 133,658
  • 13
  • 134
  • 193
Mameo96
  • 23
  • 3
  • 1
    And what would 0.10 round to? Would that round to 0.25, or down to 0? (*All* of the examples you've given would naturally round up, which doesn't help us know what you're trying to do.) – Jon Skeet Oct 21 '20 at 12:44
  • 3
    Does this answer your question? [Round a decimal to the nearest quarter in C#](https://stackoverflow.com/questions/2826262/round-a-decimal-to-the-nearest-quarter-in-c-sharp) – SomeBody Oct 21 '20 at 12:44
  • "multiply by four; round to the nearest integer (built in); divide by four"? – Marc Gravell Oct 21 '20 at 12:49
  • float x = 0.63f; x =(float)(Math.Ceiling(x / 0.25) * 0.25); //0.75 – user193679 Jun 29 '21 at 07:08

0 Answers0