Reputation: 864
I need to pack numbers in Python using the struct
module. I want to check if a number is float
or double
, when I pack it. How can I do that? Is there any built-in functions, or I need to write one? Or I need to write a class for simple Float
s instead of using python's float
s(which are actually Double
s)?
Thanks in advance!
Upvotes: 7
Views: 24479
Reputation: 117681
Python does not have C-style float
, it only has a C-style double
, which is called float
.
You must decide yourself whether you need the extra precision of a double
when you design your structures. Or, rather, you must decide whether gaining a bit of space efficiency is worth the loss of precision.
Upvotes: 10