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/067871.html below:

[Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

[Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers) [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)Greg Ewing greg.ewing at canterbury.ac.nz
Tue Aug 1 13:19:03 CEST 2006
M.-A. Lemburg wrote:

> I suppose you don't know about the optional argument
> to round that lets you round up to a certain decimal ?!

Yes, I know about, but I rarely if ever use it.
Rounding a binary float to a number of decimal
places seems a fundamentally ill-considered thing
to do anyway. What are the use cases for it,
given that one can easily select a number of decimal
places when formatting a number for display?

> If we were to follow your suggestion, we'd have round()
> return an integer when called without the argument and
> a float when called with the argument.

No, round() wouldn't have that option at all. If
you wanted it, you would use fround() instead,
which would have the option and return a float
always.

This would be a Py3k thing, obviously. If done
before then, the new function would have to be
given a different name.

--
Greg
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