Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-16 Thread Tim Peters
[Bengt Richter] ... > But I don't know how to build QNaNs: You can subtract infinity from infinity. While all Python behavior in the presence of NaNs, infinities, and signed zeroes is a platform-dependent accident, it you're on a box that has such things, and figure out some (accidental!) way to

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-16 Thread Bengt Richter
On Sat, 15 Jan 2005 11:00:36 -0800, Scott David Daniels <[EMAIL PROTECTED]> wrote: >G.Franzkowiak wrote: >> Scott David Daniels schrieb: >> >>> franzkowiak wrote: >>> I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract f

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread Scott David Daniels
G.Franzkowiak wrote: Scott David Daniels schrieb: If you really want to do this kind of byte fiddling: http://members.dsl-only.net/~daniels/block.html Then: from block import Block, View b = Block(4) # enough space for one float (more is fine) iv = View('i', b) # getting to it as an

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread G.Franzkowiak
Scott David Daniels schrieb: G.Franzkowiak wrote: Scott David Daniels schrieb: franzkowiak wrote: I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program: def l32(c): return ord(c[0]) + (ord(c[1])<<8) + (ord(c[2])<<16

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread Terry Reedy
"Scott David Daniels" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > franzkowiak wrote: >> I've read some bytes from a file and just now I can't interpret 4 bytes >> in this dates like a real value. An extract from my program: >> def l32(c): >> return ord(c[0]) + (ord(c[1])<<

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread Scott David Daniels
G.Franzkowiak wrote: Scott David Daniels schrieb: franzkowiak wrote: I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program: def l32(c): return ord(c[0]) + (ord(c[1])<<8) + (ord(c[2])<<16) + (ord(c[3])<<24) ... val

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread Scott David Daniels
franzkowiak wrote: I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program: def l32(c): return ord(c[0]) + (ord(c[1])<<8) + (ord(c[2])<<16) + (ord(c[3])<<24) ... value = l32(f.read(4)) <--- 3F 8C CC CD should

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread G.Franzkowiak
Scott David Daniels schrieb: franzkowiak wrote: I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program: def l32(c): return ord(c[0]) + (ord(c[1])<<8) + (ord(c[2])<<16) + (ord(c[3])<<24) ... value = l32(f.read(4))

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread Grant Edwards
On 2005-01-15, Scott David Daniels <[EMAIL PROTECTED]> wrote: >> I've read some bytes from a file and just now I can't interpret 4 bytes >> in this dates like a real value. > OK, here's the skinny (I used blocks & views to get the answer): > > import struct > bytes = ''.join(chr(int(txt, 16)) fo

interpret 4 byte as 32-bit float (IEEE-754)

2005-01-15 Thread franzkowiak
Hello, I've read some bytes from a file and just now I can't interpret 4 bytes in this dates like a real value. An extract from my program def l32(c): return ord(c[0]) + (ord(c[1])<<8) + (ord(c[2])<<16) + (ord(c[3])<<24) ... value = l32(f.read(4)) <--- 3F 8C CC CD should be 1.11 Anyb