• Please try to see the trailing decimal digits using

    print convert(decimal(38,36),@i)

    I think the 1st example behaved well because it was dealing with an even number (8), while the 2nd does not because it was with odd numbers (7).

    Because float comparison does not behave uniformly in all cases, I think this is why float comparison should not be used to test for equality, this is "equal", = and "not equal", <>.

    But float may be used for less than or greater than, if accuracy/significance is required then the ideal less actual result may be used re: "while (ideal - actual) > 0.0001". The latter assumes the operations will converge close to the ideal point, otherwise there must be additional codes to check if divergence is happening in order to put a stop operation.