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


Groups > comp.lang.python > #10909

Re: problem with bcd and a number

References <a59a0314-4fab-4a57-a648-daa2570f2f94@v7g2000vbk.googlegroups.com> <4E3AF2FA.7000207@ieee.org> <CAC6CgJ9QRRe+OU=RG+cK0NJuwdQw07qjR-Du98gi4O+NRicQ6A@mail.gmail.com> <CAGGBd_owY1Jyb40nw29zwQDcFu+UrfCnWBLY-J9KGnzsbLvugg@mail.gmail.com>
Date 2011-08-05 16:32 +0100
Subject Re: problem with bcd and a number
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1928.1312558326.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Aug 5, 2011 at 1:40 AM, Dan Stromberg <drsalists@gmail.com> wrote:
>>>> print int(hex(0x72).replace('0x', ''))
> 72

Or simpler: int(hex(0x72)[2:])

Although if you have it as a string, you need to ord() the string.

It's probably better to just do the bitwise operations though.

ChrisA

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