` Printed Icetips Article

Icetips Article



Par2: Swedish rounding
2005-03-24 -- Greg Bailey
 
> A fun fact about New Zealand: The monetary system revolves around Swedish 
> rounding. Back around 6 years ago when the switch to plastic money happened, 
> New Zealand got rid of the penny and instituted a crazy rounding scheme. 
> Here's how it goes: middle numbers (3, 4, 5, 6, and 7) all round to 5, and 
> end numbers (8, 9, 0, 1, and 2) round to 0. So something that's 3.97 rounds 
> to 3.95. Got it? Good, you're on your way to becoming Kiwi.

I don't see how you can do it without examining each number.  Something
like this.
NbrString string( 20 )

NbrString = format( Amount, n020.2 ) !force to fill string
case NbrString[ 20 ]
  of 8 to 9
  orof  1 to 2
    NbrString[ 20 ] = 0
  of    3 to 7
    NbrString[ 20 ] = 5
end!case
Amount = NbrString



Printed November 21, 2024, 6:36 am
This article has been viewed/printed 35374 times.