Decimal vs Float comparasion

Y

Yuan HOng

Hi,

It seems decimal object will always be larger than float in
comparasion, which goes against common sense:
True

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.

--
Hong Yuan

´ó¹Ü¼ÒÍøÉϽ¨²Ä³¬ÊÐ
×°ÐÞ×°ä꽨²Äһվʽ¹ºÎï
http://www.homemaster.cn
 
G

Gasto

I still don't see why such a module exists.

Hi,

It seems decimal object will always be larger than float in
comparasion, which goes against common sense:


True

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.

--
Hong Yuan

´ó¹Ü¼ÒÍøÉϽ¨²Ä³¬ÊÐ
×°ÐÞ×°ä꽨²Äһվʽ¹ºÎïhttp://www.homemaster.cn
 
M

Marco Mariani

Gasto said:
I still don't see why such a module exists.

There are 2.0 types of programmers: those who always use floating point,
and those who know how to use them.
 
R

Rhamphoryncus

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?

Yes, it is fixed in 3.0. Unfortunately it's well established
behaviour in 2.x, so it won't be changing there. Don't bother
reporting a bug about this unless it's about 3.0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top