in reply to Re: Rounding a number using (s)printf
in thread Rounding a number using (s)printf

Could you please first to read the entire question before babbling your response?

First of all, you're wrong. The OP expected the results for 0.256, 0.255 and 0.254 to be 0.26, 0.26 and 0.25. And lo and behold, they were 0.26, 0.26 and 0.25. Because everyone learns in primary school that if the part we truncate starts with 5 or greater (and not "greater than 5"), we up the last digit.

But the OPs problem wasn't with that. The OPs problem was the inconsistency of 0.255 being rounded up, and 1.255 being rounded down.

That, however, you don't address. Others in the thread luckely did.

  • Comment on Re^2: Rounding a number using (s)printf