I've made this algorithm to test how python compares close numbers
x = 2.5 # arbitrary number chosen to do the testing
y = float(input('Insert Y ')) #
print('X > Y = {}'.format(x > y)) # shows whether x>y
print('X = Y = {}'.format(x == y)) # shows whether x = y
print('X < Y = {}'.format(x < y)) # shows whether x < y
For y = 2.50000000000000001, which has the minimum amount decimal places for Python to automatically round the number. Execution:
Insert Y 2.50000000000000001
X > Y = False
X = Y = True
X < Y = False
Process finished with exit code 0
How to make Python realise X is less than Y, not rounding it?