#ifndef INFINITY
#ifdef _MSC_VER
union MSVC_EVIL_FLOAT_HACK
{
unsigned __int8 Bytes[4];
float Value;
};
static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
#define INFINITY (INFINITY_HACK.Value)
#endif
I'm currently getting started with the Chipmunk physics engine and found this in a header file
INFINITY is used to set infinite momentum for objects, however I don't understand what this code above does!
It sets INFINITY to the float value represented by the hex bits 0x7f800000, which is +INF
. Visual Studio doesn't define INFINITY for some reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With