round probleme under python 2.0

Rainy sill at optonline.net
Sat May 19 11:58:48 EDT 2001


On Sat, 19 May 2001 17:44:46 +0200, William Famy <william.famy at noos.fr> wrote:
> good morning.
> 
> I have a problem with python 2.0 under gnu linux debian/sid.
> round seem not working well. any idea to solve the problem?
> 
> Thanks for any answers.
> 
> _________________
> Under Python 2.0
> 
>>>> b
> 2.8465416541454847
>>>> [v,b]
> [31.665164691616152, 2.8465416541454847]
>>>> [round(v,2),round(b,2)]
> [31.670000000000002, 2.8500000000000001]
>>>> round(v,2)
> 31.670000000000002

As far as I understand, 1.5 was lying to you. If you want
2.0+ to lie also, you can either use
>>> print round(v,2)
31.67
or
>>> repr(round(v,2))
31.67

> 
> _________________________________
> under python 1.5
> 
>>>> v=31.665164691616151351651654651651
>>>> v
> 31.6651646916
>>>> b=2.84654165414548456465165651651651465
>>>> b
> 2.84654165415
>>>> [v,b]
> [31.6651646916, 2.84654165415]
>>>> [round(v,2),round(b,2)]
> [31.67, 2.85]
>>>>
> --
>                             \\\|///
>                           \\  - -  //
>                            (  @ @  )
> +-----------------------oOOo-(_)-oOOo--------------------+
>|Famy William  36 avenue des barattes 74000 Annecy France|
>|email:william.famy at noos.fr                              |
>|      william.famy at mail-enseignant.com                  |
> +--------------------------------Oooo--------------------+
>                            oooO   (   )
>                           (   )    ) /
>                            \ (    (_/
>                             \_)
> 
> 
> 


-- 
Jupiter and Saturn Oberon Miranda
And Titania Neptune Titan
Stars can frighten
        - Syd



More information about the Python-list mailing list