# Floating point iterations fail

Iteration works with integers but fails with floating numbers.
I recently wrote code for an iteration to decrement a number something like this:

While (number) is less than (end number)
number = number - (number to subtract)
If (number) = (expected number)
print True
Else
print false

If I start with 10 and subtract 1 until I get to 1 it works fine, however,
I I start with 1 and subtract .1 until I get to .1 it fails.
Why?

Why not show your relevant blocks and screen output?

Where is the variable expectedNumber coming from ?

How do I do that?

If I iterate down to a certain number number then I expect that number.
integers work, floating point doesn't.

You have stumbled upon a feature of floating point numbers.
Decimal 1/10 is an unending decimal fraction in binary floating point,
like 1/3 is unending in decimal representation.

There is no exact floating point representation of .1 iin AI2.

If you must deal in decimal fractions, use the math block that formats them as decimal text.

Well I tried that but it still doesn't work
If I set variable to decimal 1 then do a while loop subtracting decimal 0.1 while > decimal 0.1
then I get 1.3878E-16

I will try the format block and see what happens.

Finally figured it out. Thanks