Decimal arithmetic, was Re: Python GUI app to impress the boss?

Dennis Lee Bieber wlfraed at ix.netcom.com
Wed Oct 2 19:49:19 EDT 2002


Steve Holden fed this fish to the penguins on Wednesday 02 October 2002 
07:04 am:

> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in
> message news:mailman.1033528684.23114.python-list at python.org...
>>
>>     "Banker's" rounding:
>>         > 0.5 up, < 0.5 down, ties broken by rounding
>>             to the next even unit
>>
> 
> Then there's what I'll call "numerical analyst's rounding", intended
> to remove the bias of always rounding the same way at the boundary. I
> may be wrong here; I took the classes in 1973 ....
> 
>    > 0.5 (units) round away from zero,
>    < 0.5 round towards zero
>     = 0.5: round towards zero if next most significant digit is odd,
>              otherwise away from zero.
>
        Same as "Banker's" with the difference that you are rounding to an 
odd, and Banker's rounded to an even...

                B               nar
        0.5     0               1
        1.5     2               1
        2.5     2               3
        3.5     4               3

sum     8.0     8               8

--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list