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


Groups > comp.lang.python > #10872

Re: problem with bcd and a number

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news.cgarbs.de!news.addix.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail
From Christoph Hansen <ch@radamanthys.de>
Newsgroups comp.lang.python
Subject Re: problem with bcd and a number
Date Thu, 04 Aug 2011 21:31:19 +0200
Organization 1&1 Internet AG
Lines 26
Message-ID <j1es27$e64$1@online.de> (permalink)
References <a59a0314-4fab-4a57-a648-daa2570f2f94@v7g2000vbk.googlegroups.com>
NNTP-Posting-Host p54b0110b.dip0.t-ipconnect.de
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace online.de 1312486279 14532 84.176.17.11 (4 Aug 2011 19:31:19 GMT)
X-Complaints-To abuse@einsundeins.com
NNTP-Posting-Date Thu, 4 Aug 2011 19:31:19 +0000 (UTC)
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110501 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <a59a0314-4fab-4a57-a648-daa2570f2f94@v7g2000vbk.googlegroups.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10872

Show key headers only | 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