I am reading a piece of code. I believe this is in C++:
union Float_t
{
Float_t(float num = 0.0f) : f(num) {}
// Portable extraction of components.
bool Negative() const { return (i >> 31) != 0; }
int32_t RawMantissa() const { return i & ((1 << 23) - 1); }
int32_t RawExponent() const { return (i >> 23) & 0xFF; }
int32_t i;
float f;
#ifdef _DEBUG
struct
{ // Bitfields for exploration. Do not use in production code.
uint32_t mantissa : 23;
uint32_t exponent : 8;
uint32_t sign : 1;
} parts;
#endif
};
Can someone explain two things?
1..
Float_t(float num = 0.0f) : f(num) {}
What is this line saying? What does f(num) mean when f isn't defined?
2.. Why are #ifdef _DEBUG and #endif necessary in the latter part of the code?
Thanks.