On 2005-12-06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm using python to run some lab equipment using PyVisa. When I read a > list of values from the equipment, one of the fields is 32 bits of > flags, but the value is returned as a floating point number, either in > ASCII format, or pure binary.
Wha? That doesn't make any sense. If it's 32 bits of flags, then it's not a floating point number "in pure binary". I suppose you could pretend the 32 bit chunk is a float and print the resulting value, but that's just insane. And it won't work. For some bit patterns, there's no way to go from ASCII back to that same bit pattern. IOW, there is not a 1:1 mapping between bit patterns and the string representation, so if that's what you've got, you're screwed. > In either case, since I'm using PyVisa, it converts the number > to a single precision floating point, and that's what I have > to work with. It sounds like PyVisa is broken if it's treating someting as a float when it isn't. > The question is how do I recover the bits out of this floating > point value so I can read the flags represented here? Use the struct module. > Also, it's little (or big?) endian. Whatever... how do I > manipulate the endianness? Again, the struct module. -- Grant Edwards grante Yow! ... I have read the at INSTRUCTIONS... visi.com -- http://mail.python.org/mailman/listinfo/python-list