Why Doesn't This Code Work?

This will explain it all.

In an IEEE single-floating point number you can represent certain numbers perfectly and unambiguously.

For instance, 0.5f is precisely represented as 0x3f000000

However, 0.1f CANNOT be precisely represented. One possible approximate representation is 0x3DCCCCCD

The analogy is that you cannot show 1/3rd precisely as a decimal.

0.33 is correct to 2 decimal places
0.3333 is correct to 4 places
etc.

But you can never exactly represent 1/3rd as a decimal numeral. You just get closer.

Three times 0.33 (one possible representation of 1/3rd) is 0.99… and last I checked, 0.99 does not equal 1.0… and yet “three times one third” should be 1.0.

Since computers store everything internally as binary (that’s how digital computers work!), you can NEVER, no matter how big a binary number you make, precisely represent 0.1f

And in your example 0.2f is simply 0.1f times 2, so not representable precisely.

But you CAN use other ways to represent it, such as with a C# Decimal, but that is nowhere near as efficient computationally, and is rarely ever used. I don’t even know if Unity’s .NET supports Decimal.

I Have A Rounding Problem That I Can't Seem To Fix
Why give me contactfilter a wrong "false"?
My ship wont move on
How to create a time slow down effect for everything but my player ?
playerprefs compare values
Getting The Element Int OF An Array
Floats Not Working
How can I make a trigger in 2d
Objects on the phone are sometimes on a totally wrong place
Uniform RigidBody acceleration->deceleration not ending up at exact target location
Rotate the camera smoothly around an object.
Problem with transform.position (938455)
Float used in expression works perfectly, but if I save the float as a variable it will not
Check if line hits start and end (917548)
[SOLVED] : Explicit match on x and y velocities of a rigid body and jump function
Physics2D.Raycast distance
Character moves without pressing any buttons.
localPosition float comparison fails for seemingly no reason
Check if x position is moving
Animator Parameter can't be set to zero through code
2D Astronomical Simulation
Same color is not same color on spriterenderer?
Unity strange values when rotating an object (9.659347e-06 and 90.00001)
Recreatable incorrect raycast miss on capsule collider
Inconsistent procedural terrain
Been coding for a bit, self taught, and this question has been nagging for a while and finally decided to ask. Why is "Mathf" so poor out of the box?
Can't access transform rotation from script
Lerp not going into negative field
Vector3.MoveTowards move object with different speed on different frame rate
Rotating Specific Amount In The Correct Direction on Key Press
How to get rotation of a Game Object??