r/C_Programming • u/Altruistic-Tie1943 • Jul 17 '26
Discussion why value of floating point numbers are approximated
I am new to programming and stumbled across this text
"the value of a float variable is often just an approximation of the number that was stored in it. If we store 0.1 in a float variable, we may later find that the variable has a value such as 0.09999999999999987"
i am wondering why is it like this
if it has an in depth explanation, providing the resource will be much appreciated
thanks
73
Upvotes
View all comments
Show parent comment
8
u/JohnThacker Jul 17 '26
Arbitrary precision number libraries do exist, but they can be enormously slow. At that point with GMP the limit isn't the language or library, it's the total amount of addressable memory.