float separationn

Michael Hudson mwh at python.net
Thu May 16 06:03:10 EDT 2002


Wolfgang Draxinger <wdraxinger at darkstargames.de> writes:

> This is not really C/C++ related, but I think this is also a place to ask:
> I'm currently working on a compressed 3D Object interchange format.
> With C/C++ its no problem to raw-write the IEEE standard floats the
> data consists of into files. Now I'm writing some export scripts for
> blender in python. My problem is, that the python float object doesn't
> provide a raw-data access. What I need now, is some possibility to
> construct the IEEE float format from data returned by the standard
> math functions.

>>> struct.pack('d', math.pi)
'\x18-DT\xfb!\t@'
>>> struct.unpack('d', _)[0]
3.1415926535897931

Whether that's IEEE format is a platform dependent crap shoot, I
think, but probably no more than it is with C++.

Cheers,
M.

-- 
  Also, remember to put the galaxy back when you've finished, or an
  angry mob of astronomers will come round and kneecap you with a
  small telescope for littering. 
       -- Simon Tatham, ucam.chat, from Owen Dunn's review of the year



More information about the Python-list mailing list