How do I compare an integer and a floating-point value the right way™?
The builtin comparsion operators give incorrect results in some edge cases, for examp
(Restricting this answer to positive numbers; generalisation is trivial.)
Get the number of bits in your exponent for the float on your platform along with the radix. If you have an IEEE754 32 bit float then this is a trivial step.
Use (1) to compute the largest non-integer value that can be stored in your float. std::numeric_limits doesn't specify this value, annoyingly, so you need to do this yourself. For 32 bit IEEE754 you could take the easy option: 8388607.5 is the largest non-integral type float.
If your float is less than or equal to (2), then check if it's an integer or not. If it's not an integer then you can round it appropriately so as not to invalidate the <.
At this point, the float is an integer. Check if it's within in the range of your long long. If it's out of range then the result of < is known.
If you get this far, then you can safely cast your float to a long long, and make the comparison.