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

2013-06-13 Thread Tim Roberts
Fábio Santos wrote: >On 5 Jun 2013 06:23, "Tim Roberts" 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. Well, Cybers weren

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

2013-06-12 Thread Grant Edwards
On 2013-06-12, F?bio Santos wrote: > On 5 Jun 2013 06:23, "Tim Roberts" 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. O

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" 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. -- http://mail.python.org/mailman/listinfo/pyt

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 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. -- http://mail.python.org/mailman/listinfo/python

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

2013-06-04 Thread Tim Roberts
Grant Edwards wrote: >On 2013-06-03, Dan Stromberg 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 recollection is that incrementin

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 wrote: > On 4 June 2013 14:39, Grant Edwards wrote: >> On 2013-06-03, Dan Stromberg 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

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 wrote: > On 2013-06-03, Dan Stromberg 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 still being > sold in the DSP marke

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 H

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

2013-06-04 Thread Grant Edwards
On 2013-06-03, Carlos Nepomuceno 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 tho

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

2013-06-04 Thread Grant Edwards
On 2013-06-03, Dan Stromberg wrote: > On Mon, Jun 3, 2013 at 7:31 AM, Grant Edwards wrote: > >> 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. >> >> Quoti

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 >

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

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 wrote: > 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 http://en.wikipedia.org/wiki/Byte > >

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

2013-06-03 Thread Grant Edwards
On 2013-06-03, Dave Angel wrote: > On 06/03/2013 10:31 AM, Grant Edwards wrote: >> On 2013-06-03, Dennis Lee Bieber wrote: >>> On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen >>> declaimed the following in >>> gmane.comp.python.general: >>> >>> b'7' is the byte with the character 7 in a c

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 wrote: On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen 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 int

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

2013-06-03 Thread Grant Edwards
On 2013-06-03, Dennis Lee Bieber wrote: > On Sun, 02 Jun 2013 21:25:45 +0200, Mok-Kong Shen > 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 int to a byte, with that int in either

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 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 it, in which case it g

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

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

2013-05-30 Thread jmfauth
On 30 mai, 20:42, Ian Kelly wrote: > On Thu, May 30, 2013 at 12: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 reconstru

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 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? >>> >> T

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: http://docs.py

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

2013-05-28 Thread Grant Edwards
On 2013-05-27, 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? One way is using the struct module. -- Grant Edwards grant.b.edwardsYow! Uh-oh!! I forgot

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

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: &g

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

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: http://docs.python.org/3.3/library/stdtypes.html#int.from_

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

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