I know that values that can be exactly represented in decimal floating point are often unable to be represented as exact values in binary floating point. It is easy to demonstrate in e.g. python
a = float("0.5")
print('%.17e' % (a))
5.00000000000000000e-01
a = float("0.054")
print('%.17e' % (a))
5.39999999999999994e-02
a = float("0.055")
print('%.17e' % (a))
5.50000000000000003e-02
That's entirely to be expected and perfectly proper. But what I want to know is whether there is an easy way of finding out whether the converted value is higher or lower than the exact value (or indeed if it converts exactly). From the examples above I could obviously do something with the output string but that seems extraordinarily clumsy, and it is such a useful thing to know (for example if you are incrementing a floating point number in a loop you can use it to decide whether you are going to get the expected number of iterations or not) that I am hoping there is a more straightforward way of doing this. I'm only using python as an example here - I'd prefer a language agnostic solution.