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


Groups > comp.lang.python > #10910

Re: problem with bcd and a number

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.12; 'bitwise': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'string,': 0.18; 'subject:problem': 0.19; 'though.': 0.23; 'aug': 0.24; 'print': 0.29; 'operations': 0.30; 'from:addr:web.de': 0.30; 'subject:number': 0.30; 'chris': 0.32; 'probably': 0.33; 'to:addr :python-list': 0.33; 'header:X-Complaints-To:1': 0.35; 'fri,': 0.36; 'skip:i 30': 0.37; 'received:org': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: problem with bcd and a number
Date Fri, 05 Aug 2011 17:52:38 +0200
Organization None
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> <CAPTjJmpHtUT0tKX0WYxjZdTvxHaW4wt5hBn0i4gJc4KeEqfpnQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084a0fc.dip.t-dialin.net
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1929.1312559562.1164.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312559562 news.xs4all.nl 23936 [2001:888:2000:d::a6]:56469
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10910

Show key headers only | View raw


Chris Angelico wrote:

> 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.

Or use str.encode():

>>> int("\x72".encode("hex"))
72
>>> int("\x12\x34\x56".encode("hex"))
123456

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

Back to comp.lang.python | Previous | NextPrevious 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