Decimal vs Float comparasion

Gasto gabriel.hasbun at gmail.com
Tue May 6 00:00:24 EDT 2008


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

 On 5 mayo, 21:52, "Yuan HOng" <hongyuan1... at gmail.com> wrote:
> Hi,
>
> It seems decimal object will always be larger than float in
> comparasion, which goes against common sense:
>
> >>> from decimal import Decimal
> >>> a = Decimal('0.5')
> >>> a > 99999
> False
> >>> a > 99999.0
>
> 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




More information about the Python-list mailing list