[python-win32] ATT DSP32C to IEEE

Thomas Heller theller at python.net
Fri Jan 13 18:20:24 CET 2006


Ray Schumacher <rays at blue-cove.com> writes:

> At 08:00 AM 1/6/2006, Thomas Heller wrote:
>
>>RayS <rays at blue-cove.com> writes:
>>
>>> I'm trying to find an efficient way to convert from DSP32C binary files
>>> smmmmmmm mmmmmmmm mmmmmmmm eeeeeeee
>>> to IEEE float
>>> seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
>>>
>>> I tried struct and bit-shifting from a C manual example, but it 
>>> failed. Has someone else coded this in Python? I'll post the early 
>>> attempt when I get into the office later, if not.
>>>
>>> I re-coded from scratch, converting each 32 bit ATT value to a binary 
>>> string, slice-rearranging bits, then re-packing to IEEE. A bit 
>>> slowwwww. At least they're small files.
>>
>>You could try ctypes bitfield structures, maybe, to access the fields?
>
> Sounds interesting, but I have not used them; and on
> http://starship.python.net/crew/theller/ctypes/tutorial.html
> you wrote
> "Bugs, ToDo and non-implemented things
> Bitfields are not implemented."
> Are they available? Documented?
> I have __version__ = "0.9.6"

Available - yes (also in 0.9.6 I think).  Documented - no.


> I also just read
> http://publications.gbdirect.co.uk/c_book/chapter6/bitfields.html
> which warned "Be careful using them. It can require a surprising
> amount of run-time code to manipulate these things and you can end up
> using more space than they save.  Bit fields do not have addresses­you
> can't have pointers to them or arrays of them."

This is probably true, but meant as a warning to C programmers.
Apparently when using predefined structures you have no other choice
than to use them.

Thomas



More information about the Python-win32 mailing list