problem with bcd and a number

Christoph Hansen ch at radamanthys.de
Thu Aug 4 15:31:19 EDT 2011


nephish schrieb:

> thanks for any tips on this.

I'll try.

In BCD a (decimal) digit is stored in a halfbyte (or a 'nibble'). So, in 
a byte
you can store two decimal digits. For instance 42 would be

nibble1 nibble2
0100     0010
4            2

 >>> c=0b01000010
 >>> c
66
 >>> c >> 4               # first nibble
4
 >>> c & 0b1111     # second nibble
2


So, a speed of 57% should be
LSB= 0111 0000
MSB= 0000 0101



More information about the Python-list mailing list