Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using struct.pack

Status
Not open for further replies.

Bong

Programmer
Dec 22, 1999
2,063
US
Greeting,
I can't seem to get what I think should happen using struct with floating point format. Say I want to pack 0.5:
Code:
>>> import struct
>>> struct.pack('f',.5)
'\x00\x00\x00?'
>>>

I would expect 4 bytes and the first one at least ought to be non-zero. Is this a problem with struct or with me?


_________________
Bob Rashkin
 
Hi

According to Perl's [tt]pack[/tt] :
man perlfunc | pack said:
f A single-precision float in the native format.
I would say, floating point values textual aspect not needs to be human readable. Which means, I consider that correct.

If the problem is with the struct module, then an identical problem is in Perl too...

Feherke.
 
Maybe not human readable, but surely not all zeros, right?

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top