Its a way to initialize the memory occupied by the float variable to 0x7f800000. As @Jim says, this is + infinity in the float.
The code is roughly equivalent:
byte Bytes[4] = { 0x00, 0x00, 0x80, 0x7F }; float Value; memcpy(&Value, Bytes, 4); #define INFINITY_HACK (Value)
First, the source code defines a union that allows you to manipulate four bytes of memory, either as an array of four bytes, or as a single float (which, we assume, also takes four bytes):
union MSVC_EVIL_FLOAT_HACK { unsigned __int8 Bytes[4]; float Value; };
He then selects the union instance named INFINITY_HACK and sets the values of its Bytes array to the specified hexadecimal values .:
static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
This causes the field to be float initialized, since it also takes up the same memory as the byte array.
Finally, it defines a constant for the processor called INFINITY as a float value.
Andy johnson
source share