U
Ulrich Eckhardt
Hi!
I need to pack a floating point value into a vector of 32-bit unsigned
values in IEEE format. Further, I maintain a CRC32 checksum for integrity
checking. For the latter, I actually need the float as integral value.
What I currently do is this:
tmp = struct.pack("=f", f)
(i,) = struct.unpack("=L", tmp)
IOW, I pack and unpack the float using the struct module, which works.
What I'm wondering is whether there are any better or alternative ways to
achieve this, the overhead now seems enormous and unnecessary to me here.
Thank you!
Uli
I need to pack a floating point value into a vector of 32-bit unsigned
values in IEEE format. Further, I maintain a CRC32 checksum for integrity
checking. For the latter, I actually need the float as integral value.
What I currently do is this:
tmp = struct.pack("=f", f)
(i,) = struct.unpack("=L", tmp)
IOW, I pack and unpack the float using the struct module, which works.
What I'm wondering is whether there are any better or alternative ways to
achieve this, the overhead now seems enormous and unnecessary to me here.
Thank you!
Uli