You&#x27;ve just redefined your problem to using floats as the underlying representation. In that case you don&#x27;t even need floats...<p>In most other cases the correct way is to check if the absolute value of the difference between one value and another is smaller than some arbitrary cut-off, a small number typically denoted with &#x27;epsilon&#x27;.