Monday, 9 September 2013

C++ declare platform independent 32-bit float

C++ declare platform independent 32-bit float

Is there a way to declare 32-bit floating point value in C++ - ensuring
that it will always be 32 bits regardless of platform/compiler?
I can do that for integers like that:
#include <stdint.h>
uint32_t var; //32 bit unsigned integer
uint64_t var1; //64 bit unsigned integer
is there a way to do something like that for floats? As far as I know,
float var; //Usually is 32 bit, but NOT GUARANTEED to be 32 bit
is implementation specific, and is not necessarily 32 bit.. (Correct me if
I am wrong).
I am using qt, so if there is any solution using it I would accept it - I
couldn't find anything like quint16 for floats (qreal changes size
depending on platform).

No comments:

Post a Comment