I have a union
defined as follows:
union V64
{
double f64;
__int64 i64;
unsigned __int64 u64;
};
I'd like to do a lazy comparison (equality and inequality) of a 8-byte value of unknown type against another V64
of known type. Will comparing the i64
of two V64
s consistently give me the expected result, regardless of the underlying type? For example:
V64 a.u64 << 9007199254740993+500; //pseudo-code reading raw bytes
V64 b.u64 << -9007199254740993-501; //pseudo-code reading raw bytes
if(a.i64 > b.i64)
{/*do stuff*/}
Comparing u64
breaks down when one is negative and f64
breaks down when the value exceeds double
's int
storage (2^53 +1). Comparing i64
appears to work, but there might be a case I haven't considered.