FV-SOL-2-C2 Floating Point
TLDR
Floating-point numbers can’t represent every decimal exactly. For example, 0.3
might be stored as 0.30000000000000004
in a system that uses floating-point arithmetic.
When you divide and multiply these imprecise values, the error compounds. For example, (0.3 / 1000.0) * 1.0
could produce something like 0.00030000000000000004
instead of the expected 0.0003
.
This often occurs when dealing with fractional values or very large numbers, where small rounding errors can accumulate and lead to inaccurate calculations or financial discrepancies.
Game
What is the result of userReward
? can you tell?
Last updated
Was this helpful?