[Python-Dev] New operations in Decimal

Nick Coghlan ncoghlan at gmail.com
Sat May 12 02:43:49 CEST 2007


Greg Ewing wrote:
> Terry Reedy wrote:
>> I had the same opinion until I saw the logic stuff.
> 
> The only rationale I can think of for such a thing is
> that maybe they're trying to accommodate the possibility
> of a machine built entirely around a hardware implementation
> of the spec, that doesn't have any other way of doing
> bitwise logical operations.
> 
> If that's the case, then Python clearly has no need
> for it.

That is my interpretation of the spec as well. I'd prefer to see a 
decimal.BitSequence subtype added to the module rather than lumping the 
functionality into the main decimal.Decimal type.

The specification itself makes it clear that these operations are not 
supported for the full range of decimal numbers:

"The logical operations (and, invert, or, and xor) take logical 
operands, which are finite numbers with a sign of 0, an exponent of 0, 
and a coefficient whose digits must all be either 0 or 1."

The footnote attached to the quoted sentence also makes it clear that 
this is about still being able to do binary logic operations with a 
purely decimal ALU:

"This digit-wise representation of bits in a decimal representation has 
been used since the 1950s; see, for example, Binary and truth-function 
operations on a decimal computer with an extract command, William H. 
Kautz, Communications of the ACM, Vol. 1 #5, pp12-13, ACM Press, May 1958."

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list