Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75501
| X-Received | by 10.182.232.164 with SMTP id tp4mr3571652obc.29.1406928340529; Fri, 01 Aug 2014 14:25:40 -0700 (PDT) |
|---|---|
| X-Received | by 10.140.19.97 with SMTP id 88mr23447qgg.31.1406928340502; Fri, 01 Aug 2014 14:25:40 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!h18no7675509igc.0!news-out.google.com!b3ni5434qac.1!nntp.google.com!v10no3827692qac.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Fri, 1 Aug 2014 14:25:40 -0700 (PDT) |
| In-Reply-To | <mailman.12523.1406926051.18130.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=96.253.122.47; posting-account=hWNcmQoAAABqBBZN8EaDElImHt5ToXFd |
| NNTP-Posting-Host | 96.253.122.47 |
| References | <17160115-a77f-436a-837c-cd2039a7c53f@googlegroups.com> <mailman.12523.1406926051.18130.python-list@python.org> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <f69f7aca-c744-452b-bbaa-e21699e42b5d@googlegroups.com> (permalink) |
| Subject | Re: Creating a 2s compliment hex string for negitive numbers |
| From | bSneddon <w.g.sneddon@gmail.com> |
| Injection-Date | Fri, 01 Aug 2014 21:25:40 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:75501 |
Show key headers only | View raw
On Friday, August 1, 2014 4:47:20 PM UTC-4, MRAB wrote: > On 2014-08-01 21:35, bSneddon wrote: > > > I need to calculate an error correction code for an old protocol. > > > > > > I calculate the integer 4617 and want to code the 2s compliment in ASCII > > > hex EDF7. When issue the following. > > >>>> hex(-4617) > > > '-0x1209' > > > > > > Does anyone know a clean way to get to the desired results? My ECC will always > > > be 16 bit (4 nibble) hex number. > > > > > Use a bitwise AND: > > > > >>> hex(-4617 & 0xFFFF) > > '0xedf7' Thanks
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Creating a 2s compliment hex string for negitive numbers bSneddon <w.g.sneddon@gmail.com> - 2014-08-01 13:35 -0700
Re: Creating a 2s compliment hex string for negitive numbers MRAB <python@mrabarnett.plus.com> - 2014-08-01 21:47 +0100
Re: Creating a 2s compliment hex string for negitive numbers bSneddon <w.g.sneddon@gmail.com> - 2014-08-01 14:25 -0700
csiph-web