Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10872

Re: problem with bcd and a number

From Christoph Hansen <ch@radamanthys.de>
Newsgroups comp.lang.python
Subject Re: problem with bcd and a number
Date 2011-08-04 21:31 +0200
Organization 1&1 Internet AG
Message-ID <j1es27$e64$1@online.de> (permalink)
References <a59a0314-4fab-4a57-a648-daa2570f2f94@v7g2000vbk.googlegroups.com>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

problem with bcd and a number nephish <nephish@gmail.com> - 2011-08-04 11:31 -0700
  Re: problem with bcd and a number Dave Angel <davea@ieee.org> - 2011-08-04 15:28 -0400
  Re: problem with bcd and a number Christoph Hansen <ch@radamanthys.de> - 2011-08-04 21:31 +0200
  Re: problem with bcd and a number Chris Angelico <rosuav@gmail.com> - 2011-08-05 16:32 +0100
  Re: problem with bcd and a number Peter Otten <__peter__@web.de> - 2011-08-05 17:52 +0200

csiph-web