I have a library function RoundDouble() which takes a double value and rounds to 2DP. This is mostly use for display and other applications where trimming is required, but I have used it to compare values with strange results.
I use Visual Studio 10 Professional to build solutions.
The test :
if( RoundDouble(a) > RoundDouble(b) )
frequently returns TRUE, even when both values are identical BOTH rounded AND before rounding. I have of course used debugging to test the values being compared.
No, there is nothing you can do to fix that - that is an inherent property of floating point math. If you need exact precision with your calculations, don't use a floating point type.
Casting away the decimal places is definitely not ideal. There are existing C and C++ libraries for exact math with decimal types, for example: https://gmplib.org/