Please help...I am having a problem with comparing double values in C++. I have stumble across this issue when my sorting algorithm tries to compare double values to check whether a < b / a > b. Based on the comparison result my sorting algorithm does sorting by ascending or sorting in descending order.
However when I have something like the following double value comparison it yields different behavior.
Example:
double dValue1 = 10.5
double dValue2 = 10.10;
If i'm going to compare using > operator in C++ turns out the result is different than what I am expecting.
10.5 is compared to 10.1 --> looks to me there's a rounding issue here since it doesn't account for the floating point precision.
Hope there's someone who could share his/her idea on how to fix this bug.
I mean ultimately, I would expect that 10.10 should be greater than 10.5 when we compare both double values.
Thanks,
alein