PEP0238 lament
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Jul 30 04:43:42 EDT 2001
Guido van Rossum <guido at python.org> wrote in news:cp4rrz95iu.fsf at cj20424-
a.reston1.va.home.com:
> I don't see when a unified number system would ever be less convenient
> than the current number system, *except* in the rare case where you
> are transliterating an algorithm from C that depends on integer size.
> Unsigned ints of n bits are easily emulated by taking all results
> modulo 2**n -- I do this now using Python long ints when I need to
> emulate unsigned C longs.
The main situation that I was thinking of was calculations involving
currencies, which would normally be done using int or long. You want fixed
precision and truncation of fractional results. you do not want any
automatic promotion to floating point. I think the system you are proposing
still allows for this, but it may make it easier to accidentally slip into
floating point.
> Using the new type/class unification in Python 2.2, you will be able
> to subtype the int or long types easily to create your own constrained
> types.
It may be fun trying this out.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list