However there's a gotcha. Decimal conversions to binary are not precise. Try converting 0.1 yourself into binary and see what happens. The computer can only use fixed precision; it has no way of representing repeating decimals.

So floating point comparisons need to take this inaccuracy into account, e.g.:

and of course you should set the value 0.005 according to the precision needed by the program. So if it's a banking program then you could set it to 1/100th of the smallest currency, for example if you're using British Sterling, where 100 pence make a pound, then you could check for less than 0.0001 (maybe). It really depends how much accuracy you need. If you need it to be exact then you need to use integers, so for instance you could store Sterling values as numbers of pence, or numbers of tenths of pence etc.

but i found a way around it just simply by multiply the decimal by a few thousands provided the decimal is ending.e.g compare 2.562715 and 2.562716 then i would multiply buy 1000000 then assign it to 2 integers then compare.
i am just a newbie. Thanks for your method
please keep in touch.
thanks

is just as good as the first example I posted. You'll need to make sure you have the headroom though, if you're comparing floats up to 2147483.647 then you'll be OK, but anything over that and you'll overflow the int which will produce invalid results. You mentioned "a few thousand" so if that's 10,000 then your maximum float values can be 214748.3647, which is less than a quarter million.