Question: Can two floating point values (IEEE 754 binary64) be compared as integers? Eg.

```
long long a = * (long long *) ptr_to_double1,
          b = * (long long *) ptr_to_double2;
if (a < b) {...}

```

assuming the size of `long long` and `double` is the same.

Answer: 
If you strictly cast the bit value of a floating point number to its correspondingly-sized signed integer (as you've done), then signed integer comparison of the results will be identical to the comparison of the original floating-point values, **excluding NaN values**. Put another way, this comparison is legitimate for all representable finite and infinite numeric values.

In other words, for double-precision (64-bits), this comparison will be valid if the following tests pass:

```
long long exponentMask = 0x7ff0000000000000;
long long mantissaMask = 0x000fffffffffffff;

bool isNumber =  ((x & exponentMask) != exponentMask)  // Not exp 0x7ff
              || ((x & mantissaMask) == 0);            // Infinities

```

for each operand x.

Of course, if you can pre-qualify your floating-point values, then a quick isNaN() test would be much more clear. You'd have to profile to understand performance implications.
There are two parts to your question:

1. **Can two floating point numbers be compared?** The answer to this is yes. it is perfectly valid to compare size of floating point numbers. Generally you want to avoid equals comparisons due to truncation issues see [here](https://randomascii.wordpress.com/2012/06/26/doubles-are-not-floats-so-dont-compare-them/), but 

```
if (a < b)

```

will work just fine.
2. **Can two floating point numbers be compared as integers?** This answer is also yes, but this will require casting. This question should help with that answer: [convert from long long to int and the other way back in c++](https://stackoverflow.com/questions/12031302/convert-from-long-long-to-int-and-the-other-way-back-in-c)