Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Roy Smith
In article , Grant Edwards 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 they're wedded to the hardware. They do so because they'

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 fr

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

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Grant Edwards
On 2012-07-30, Mark Lawrence wrote: > On 30/07/2012 15:16, Grant Edwards wrote: >> On 2012-07-30, Steven D'Aprano 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

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

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Roy Smith
In article , Grant Edwards 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 more than a few chugging away in corporate data centers

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Grant Edwards
On 2012-07-30, Steven D'Aprano 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 I worked on that where the FP forma

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, that

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 & 0x800

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 & 0x8000

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

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 i