[Python-Dev] Unifying decimal numbers.

Sokolov Yura falcon at intercable.ru
Wed Nov 9 08:24:04 CET 2005


Excuse my English

I think, we could just segregate tokens for decimal and real float and 
make them interoperable.
Motivation:
   Most of us works with business databases - all "floats" are really 
decimals, algebraic operations
should work without float inconsistency and those operations rare so 
speed is not important.
But some of us use floats for speed in scientific and multimedia programs.

with
from __future__ import Decimal
we could:
a) interpret regular float constants as decimal
b) interpret float constants with suffix 'f' as float (like    1.5f    
345.2e-5f  etc)
c) result of operation with decimal operands should be decimal
 >>> 1.0/3.0
0.33333333333333333
d) result of operation with float operands should be float
 >>> 1.0f/3.0f
0.33333333333333331f
e) result of operation with decimal and float should be float (decimal 
converts into float and operation perfomed)
 >>> 1.0f/3.0
0.33333333333333331f
 >>> 1.0/3.0f
0.33333333333333331f




More information about the Python-Dev mailing list