Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20566
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'advice.': 0.05; 'brad': 0.07; 'c++,': 0.07; 'python': 0.08; '>>>>': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'struct': 0.09; 'unsigned': 0.09; 'c++': 0.12; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'int': 0.18; '(most': 0.21; 'from:addr:web.de': 0.23; 'int,': 0.23; 'traceback': 0.24; 'code': 0.26; 'signed': 0.32; 'thanks': 0.32; 'there': 0.33; 'file': 0.34; 'header:X-Complaints-To:1': 0.34; 'integer': 0.34; 'last):': 0.34; 'to:addr:python-list': 0.35; 'equal': 0.36; 'received:org': 0.36; 'but': 0.37; 'could': 0.38; 'format': 0.38; 'to:addr:python.org': 0.40; 'easy': 0.60; 'range': 0.61; 'conversion:': 0.84; 'does?': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: signed to unsigned |
| Date | Fri, 17 Feb 2012 20:14:46 +0100 |
| Organization | None |
| References | <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p50849a60.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.5923.1329506097.27778.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1329506097 news.xs4all.nl 6974 [2001:888:2000:d::a6]:34118 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:20566 |
Show key headers only | View raw
Brad Tilley wrote:
> In C or C++, I can do this for integer conversion:
>
> unsigned int j = -327681234; // Notice this is signed.
>
> j will equal 3967286062. I thought with Python that I could use struct
> to pack the signed int as an unsigned int, but that fails:
>
>>>> x = struct.pack("<I", -327681234)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> struct.error: integer out of range for 'I' format code
>
> Is there an easy way in Python to do the same conversion that C or C++
> code does? Thanks for any advice.
>>> 0xffffffff & -327681234
3967286062
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
signed to unsigned Brad Tilley <kj4eit@gmail.com> - 2012-02-17 10:51 -0800
Re: signed to unsigned Chris Rebert <clp2@rebertia.com> - 2012-02-17 11:05 -0800
Re: signed to unsigned Brad Tilley <kj4eit@gmail.com> - 2012-02-17 11:10 -0800
Re: signed to unsigned Peter Otten <__peter__@web.de> - 2012-02-17 20:14 +0100
Re: signed to unsigned Brad Tilley <kj4eit@gmail.com> - 2012-02-17 11:22 -0800
Re: signed to unsigned Dave Angel <d@davea.name> - 2012-02-17 14:37 -0500
csiph-web