Re: How to get an integer from a sequence of bytes

2013-06-13 Thread Tim Roberts
Fábio Santos fabiosantos...@gmail.com wrote: On 5 Jun 2013 06:23, Tim Roberts t...@probo.com wrote: A single machine word was 60 bits, so a single register read got you 10 characters. 10 characters! Now that sounds like it's enough to actually store a word. However long words can inadverten be

Re: How to get an integer from a sequence of bytes

2013-06-12 Thread Ian Kelly
On Tue, Jun 4, 2013 at 3:49 PM, Chris Angelico ros...@gmail.com wrote: So... can we cite http://xkcd.com/859/ in two threads at once, or does that create twice as much tension? No, you just look at one of them upside-down, and then they cancel each other out. --

Re: How to get an integer from a sequence of bytes

2013-06-12 Thread Fábio Santos
On 5 Jun 2013 06:23, Tim Roberts t...@probo.com wrote: A single machine word was 60 bits, so a single register read got you 10 characters. 10 characters! Now that sounds like it's enough to actually store a word. However long words can inadverten be cropped. --

Re: How to get an integer from a sequence of bytes

2013-06-12 Thread Grant Edwards
On 2013-06-12, F?bio Santos fabiosantos...@gmail.com wrote: On 5 Jun 2013 06:23, Tim Roberts t...@probo.com wrote: A single machine word was 60 bits, so a single register read got you 10 characters. 10 characters! Now that sounds like it's enough to actually store a word. However long words

Re: How to get an integer from a sequence of bytes

2013-06-04 Thread Grant Edwards
On 2013-06-03, Dan Stromberg drsali...@gmail.com wrote: On Mon, Jun 3, 2013 at 7:31 AM, Grant Edwards invalid@invalid.invalidwrote: That's a common assumption, but historically, a byte was merely the smallest addressable unit of memory. The size of a byte on widely used used CPUs ranged from

Re: How to get an integer from a sequence of bytes

2013-06-04 Thread Grant Edwards
On 2013-06-03, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote: Date: Mon, 3 Jun 2013 15:41:41 -0700 Subject: Re: How to get an integer from a sequence of bytes From: drsali...@gmail.com To: python-list@python.org [...] Today though, it would be

RE: How to get an integer from a sequence of bytes

2013-06-04 Thread Carlos Nepomuceno
From: invalid@invalid.invalid Subject: Re: How to get an integer from a sequence of bytes Date: Tue, 4 Jun 2013 13:42:46 + To: python-list@python.org [...] VN designs are still very common in smaller CPUs (embedded stuff). DSPs perhaps... not CPUs. Even ARMs are Harvard variants.

Re: How to get an integer from a sequence of bytes

2013-06-04 Thread Joshua Landau
On 4 June 2013 14:39, Grant Edwards invalid@invalid.invalid wrote: On 2013-06-03, Dan Stromberg drsali...@gmail.com wrote: Today though, it would be difficult to sell a conventional (Von Neumann) computer that didn't have 8 bit bytes. There are tons (as in millions of units per month) of CPUs

Re: How to get an integer from a sequence of bytes

2013-06-04 Thread Chris Angelico
On Wed, Jun 5, 2013 at 5:51 AM, Joshua Landau joshua.landau...@gmail.com wrote: On 4 June 2013 14:39, Grant Edwards invalid@invalid.invalid wrote: On 2013-06-03, Dan Stromberg drsali...@gmail.com wrote: Today though, it would be difficult to sell a conventional (Von Neumann) computer that

Re: How to get an integer from a sequence of bytes

2013-06-04 Thread Tim Roberts
Grant Edwards invalid@invalid.invalid wrote: On 2013-06-03, Dan Stromberg drsali...@gmail.com wrote: When I was a Freshman in college, I used a CDC Cyber a lot; it had 6 bit bytes and 60 bit words. This was in 1985. But you couldn't address individual 6-bit hextets in memory could you? My

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Grant Edwards
On 2013-06-03, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen mok-kong.s...@t-online.de declaimed the following in gmane.comp.python.general: b'7' is the byte with the character 7 in a certain code, so that's ok. In other PLs one assigns an

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Dave Angel
On 06/03/2013 10:31 AM, Grant Edwards wrote: On 2013-06-03, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen mok-kong.s...@t-online.de declaimed the following in gmane.comp.python.general: b'7' is the byte with the character 7 in a certain

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Grant Edwards
On 2013-06-03, Dave Angel d...@davea.name wrote: On 06/03/2013 10:31 AM, Grant Edwards wrote: On 2013-06-03, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen mok-kong.s...@t-online.de declaimed the following in gmane.comp.python.general: b'7'

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Dan Stromberg
On Mon, Jun 3, 2013 at 7:31 AM, Grant Edwards invalid@invalid.invalidwrote: That's a common assumption, but historically, a byte was merely the smallest addressable unit of memory. The size of a byte on widely used used CPUs ranged from 4 bits to 60 bits. Quoting from

RE: How to get an integer from a sequence of bytes

2013-06-03 Thread Carlos Nepomuceno
Date: Mon, 3 Jun 2013 15:41:41 -0700 Subject: Re: How to get an integer from a sequence of bytes From: drsali...@gmail.com To: python-list@python.org [...] Today though, it would be difficult to sell a conventional (Von Neumann) computer that didn't

Re: How to get an integer from a sequence of bytes

2013-06-03 Thread Dan Stromberg
On Mon, Jun 3, 2013 at 4:18 PM, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote: Date: Mon, 3 Jun 2013 15:41:41 -0700 Subject: Re: How to get an integer from a sequence of bytes From: drsali...@gmail.com To: python-list@python.org [...] Today

Re: How to get an integer from a sequence of bytes

2013-06-02 Thread Mok-Kong Shen
Am 30.05.2013 21:22, schrieb Ned Batchelder: On 5/30/2013 2:26 PM, Mok-Kong Shen wrote: Am 27.05.2013 17:30, schrieb Ned Batchelder: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence

Re: How to get an integer from a sequence of bytes

2013-06-02 Thread Chris Angelico
On Mon, Jun 3, 2013 at 5:25 AM, Mok-Kong Shen mok-kong.s...@t-online.de wrote: b'7' is the byte with the character 7 in a certain code, so that's ok. In other PLs one assigns an int to a byte, with that int in either decimal notation or hexadecimal notation, or else one assigns a character to

Re: How to get an integer from a sequence of bytes

2013-05-30 Thread Mok-Kong Shen
Am 27.05.2013 17:30, schrieb Ned Batchelder: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing in the docs after int.to_bytes is int.from_bytes:

Re: How to get an integer from a sequence of bytes

2013-05-30 Thread Ian Kelly
On Thu, May 30, 2013 at 12:26 PM, Mok-Kong Shen mok-kong.s...@t-online.de wrote: Am 27.05.2013 17:30, schrieb Ned Batchelder: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of

Re: How to get an integer from a sequence of bytes

2013-05-30 Thread jmfauth
On 30 mai, 20:42, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, May 30, 2013 at 12:26 PM, Mok-Kong Shen mok-kong.s...@t-online.de wrote: Am 27.05.2013 17:30, schrieb Ned Batchelder: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual

Re: How to get an integer from a sequence of bytes

2013-05-30 Thread Ned Batchelder
On 5/30/2013 2:26 PM, Mok-Kong Shen wrote: Am 27.05.2013 17:30, schrieb Ned Batchelder: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing in the docs after

Re: How to get an integer from a sequence of bytes

2013-05-28 Thread Grant Edwards
On 2013-05-27, Mok-Kong Shen mok-kong.s...@t-online.de wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? One way is using the struct module. -- Grant Edwards grant.b.edwardsYow! Uh-oh!!

How to get an integer from a sequence of bytes

2013-05-27 Thread Mok-Kong Shen
From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? Thanks in advance. M. K. Shen -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Steven D'Aprano
On Mon, 27 May 2013 16:45:05 +0200, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? Here's one way: py n = 11999102937234 py m = 0 py for b in n.to_bytes(6, 'big'): ... m = 256*m + b ... py

Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Ned Batchelder
On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing in the docs after int.to_bytes is int.from_bytes:

Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Steven D'Aprano
On Mon, 27 May 2013 11:30:18 -0400, Ned Batchelder wrote: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing in the docs after int.to_bytes is

RE: How to get an integer from a sequence of bytes

2013-05-27 Thread Carlos Nepomuceno
From: steve+comp.lang.pyt...@pearwood.info Subject: Re: How to get an integer from a sequence of bytes Date: Mon, 27 May 2013 15:00:39 + To: python-list@python.org On Mon, 27 May 2013 16:45:05 +0200, Mok-Kong Shen wrote: From an int one can use

Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Dave Angel
On 05/27/2013 08:31 PM, Steven D'Aprano wrote: On Mon, 27 May 2013 11:30:18 -0400, Ned Batchelder wrote: On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: From an int one can use to_bytes to get its individual bytes, but how can one reconstruct the int from the sequence of bytes? The next thing