Python 3.0 new integer division

Arnaud Delobelle arnodel at googlemail.com
Wed Apr 9 21:57:30 CEST 2008


On Apr 9, 8:35 pm, Mark Dickinson <dicki... at gmail.com> wrote:
> Strictly speaking, BCD doesn't come into it:  the coefficient of a
> Decimal instance is stored simply as a string of digits.  This is
> pretty wasteful in terms of space:  1 byte per decimal digit
> instead of the 4 bits per digit that BCD gives, but it's
> convenient and fairly efficient.
>
> An alternative representation that's gained popularity recently is
> DPD (densely packed decimal), which packs 3 decimal digits into 10
> bits in a clever way that allows reasonably efficient extraction
> of any one of the 3 digits.  Decimal doesn't use this either. :)
>
> Mark

Naive question: why not just use a long + an exponent?

e.g. 132560  -> (13256, 1)
     0.534   -> (534, -3)
     5.23e10 -> (523, 8)

--
Arnaud




More information about the Python-list mailing list