Binary representation of floating point numbers

63q2o4i02 at 63q2o4i02 at
Tue Dec 6 23:25:13 CET 2005


okay, let me be more concise.  The lab equipment has two formatting
modes, ascii, and float.

In ascii mode, it returns strings that represent the numeric value, so
e.g. 3.14 is returned as '3.14'.  PyVisa, when set to read ascii mode,
will convert these strings to float with "visa.read_values()". (easy
enough to do myself too with, split(), and eval()).

In float mode, the instrument returns a sequence of bits that are
exactly the ieee754 number in the case of floats, or just the flags in
the case of flags.  PyVisa, when set to float mode, will convert
everything to float, because it is unaware apriori that one of the
fields returned is actually intended to be used as binary flags.

Secondarily, I had to set the instrument to return the bits in small
endian for it to read properly (I could aternately set PyVisa to swap
endianness for me).  I may need to manipulate this.

Actually now that I read the very confusing manual, it looks like maybe
the flags is returned as a decimal number, but it's not clear how this
is returned in either ascii or float mode.  In any case, I think I will
need to manipulate "native" numbers into binary representation.  Looks
like I should figure out the struct module...


More information about the Python-list mailing list