A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-August/067956.html below:

[Python-Dev] Rounding float to int directly ...

[Python-Dev] Rounding float to int directly ... [Python-Dev] Rounding float to int directly ...Aahz aahz at pythoncraft.com
Fri Aug 4 05:22:00 CEST 2006
On Tue, Aug 01, 2006, Ron Adam wrote:
>
> I'm -1 on implicitly converting to an int when rounding.
> 
> One reason is if your rounded (to int type) number is then used in an 
> equation you my end up with a integer result when you wanted a floating 
> point result.
> 
>  >>> 23.5/5.2
> 4.5192307692307692
>  >>> round(23.5)/round(5.2)
> 4.7999999999999998
>  >>> round(23.5/5.2)
> 5.0
>  >>> int(round(23.5))/int(round(5.2))
> 4

That's not relevant to Py3K.  Which is where this discussion should
proably move because round() ain't changing in 2.x.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."  --Brian W. Kernighan
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4