Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Ulrich Eckhardt
Am 30.07.2012 02:44, schrieb Steven D'Aprano: I wish to extract the bit fields from a Python float, call it x. First I cast the float to 8-bytes: s = struct.pack('=d', x) i = struct.unpack('=q', s)[0] Then I extract the bit fields from the int, e.g. to grab the sign bit: (i

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Mark Dickinson
On Monday, July 30, 2012 1:44:04 AM UTC+1, Steven D'Aprano wrote: 1) Are there any known implementations or platforms where Python floats are not C doubles? If so, what are they? Well, IronPython is presumably using .NET Doubles, while Jython will be using Java Doubles---in either case,

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Grant Edwards
On 2012-07-30, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: 1) Are there any known implementations or platforms where Python floats are not C doubles? If so, what are they? And the question you didn't ask: are there any platforms where a C double isn't IEEE-754? The last ones

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Roy Smith
In article jv64v5$g2n$2...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: The last ones I worked on that where the FP format wasn't IEEE were the DEC VAX According to http://en.wikipedia.org/wiki/Vax#History, the last VAX was produced 7 years ago. I'm sure there's still

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Mark Lawrence
On 30/07/2012 15:16, Grant Edwards wrote: On 2012-07-30, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: 1) Are there any known implementations or platforms where Python floats are not C doubles? If so, what are they? And the question you didn't ask: are there any platforms where

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Grant Edwards
On 2012-07-30, Mark Lawrence breamore...@yahoo.co.uk wrote: On 30/07/2012 15:16, Grant Edwards wrote: On 2012-07-30, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: 1) Are there any known implementations or platforms where Python floats are not C doubles? If so, what are they?

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Mark Dickinson
On Monday, July 30, 2012 3:16:05 PM UTC+1, Grant Edwards wrote: The last ones I worked on that where the FP format wasn't IEEE were the DEC VAX and TI's line if 32-bit floating-point DSPs. I don't think Python runs on the latter, but it might on the former. For current hardware, there's

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 12:44 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I wish to extract the bit fields from a Python float, call it x. First I cast the float to 8-bytes: s = struct.pack('=d', x) i = struct.unpack('=q', s)[0] Then I extract the bit fields from the

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Roy Smith
In article jv6ab7$jne$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: I imagine that VAXes running Unix went extinct in the wild long before VAXes running VMS. Of course they did. VMS is all about vendor lock-in. People who continue to run VAXen don't do so because

Extracting bit fields from an IEEE-784 float

2012-07-29 Thread Steven D'Aprano
I wish to extract the bit fields from a Python float, call it x. First I cast the float to 8-bytes: s = struct.pack('=d', x) i = struct.unpack('=q', s)[0] Then I extract the bit fields from the int, e.g. to grab the sign bit: (i 0x8000) 63 Questions: 1) Are there any known

Re: Extracting bit fields from an IEEE-784 float

2012-07-29 Thread Dan Sommers
On 2012-07-30 at 00:44:04 +, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I wish to extract the bit fields from a Python float, call it x. First I cast the float to 8-bytes: s = struct.pack('=d', x) i = struct.unpack('=q', s)[0] Then I extract the bit fields from the

Re: Extracting bit fields from an IEEE-784 float

2012-07-29 Thread Terry Reedy
On 7/29/2012 8:44 PM, Steven D'Aprano wrote: I wish to extract the bit fields from a Python float, call it x. First I cast the float to 8-bytes: s = struct.pack('=d', x) i = struct.unpack('=q', s)[0] Then I extract the bit fields from the int, e.g. to grab the sign bit: (i