Uncle Dino
Uncle Dino

Reputation: 864

Python: Float or Double

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 Floats instead of using python's floats(which are actually Doubles)?

Thanks in advance!

Upvotes: 7

Views: 24479

Answers (1)

orlp
orlp

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

Related Questions