A float problem in iOS when indexPath.row=1
Float32 value=0.05*indexPath.row;
it returns value=0.0500000007
but it should be 0.05
. How to fix this??
A float problem in iOS when indexPath.row=1
Float32 value=0.05*indexPath.row;
it returns value=0.0500000007
but it should be 0.05
. How to fix this??
Welcome to floating point errors.
The easiest way to fix this is just to round the number after multiplying.
You can read more about why this is happening on this random website I found on Google.