Decimal vs Float comparasion

Erik Max Francis max at alcyone.com
Tue May 6 05:18:10 EDT 2008


Dennis Lee Bieber wrote:

> On Tue, 6 May 2008 11:52:10 +0800, "Yuan HOng" <hongyuan1306 at gmail.com>
> declaimed the following in comp.lang.python:
> 
>> It seems to me that rather than allowing this to happen, comparasion
>> between the two should either be made correct (by convertion decimal
>> to float e.g.) or forbidden, like arithmatic operations between the
>> two types.
> 
> 	Why should decimal be coerced to float? Maybe float should be
> coerced to decimal?
> 
> 	Or... the programmer should explicitly specify what comparison is
> wanted -- if any...
> 
> 	Or... Isn't Python 3.x supposed to forbid mixed type comparisons
> unless the types implement suitable handling?

Bottom line is that it shouldn't silently return something insane. 
99999.0 is surely exactly representable in any modern floating point 
system, being a floating point representing of an integer, so silently 
returning a completely invalid comparison is a tremendously bad idea.

It's a bug.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   Can I walk with you / 'Till the day that the world stops turning
    -- India Arie



More information about the Python-list mailing list