A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2010-March/098555.html below:

[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k. [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.Raymond Hettinger raymond.hettinger at gmail.com
Fri Mar 19 19:42:42 CET 2010
On Mar 19, 2010, at 11:11 AM, Antoine Pitrou wrote:

> Raymond Hettinger <raymond.hettinger <at> gmail.com> writes:
>> 
>> The reason to prefer an exception is that decimal/float comparisons
>> are more likely to be a programmer error than an intended behavior.
> 
> Not more so than float/int or decimal/int or bool/int comparisons, which all 
> work.

The float/int and decimal/int comparisons have valid and common use cases.
In contrast, comparing binary floats and decimal floats is rare, and more 
likely to be an accident.

When an int is converted to a float or decimal, the result usually isn't
surprising.  The conversion of a float to a decimal is not as straight-forward
(most people don't even know that an exact conversion is possible).

Also, the float and decimal constructors also natively accept ints as inputs,
but the decimal constructor intentionally excludes a float input.


Raymond



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