When I convert a string with several decimal positions to a float, the value gets changed.
There must be a simple reason, but it is escaping me.
The code below logs two lines
12.34567 (the string value)
12.345669746398926 (the resulting float value)
How do I accurately convert a decimal string to a float value? I've tried various formatting methods and continue to get this result.
There must be a simple reason, but it is escaping me.
The code below logs two lines
12.34567 (the string value)
12.345669746398926 (the resulting float value)
How do I accurately convert a decimal string to a float value? I've tried various formatting methods and continue to get this result.
B4X:
Dim str1 = "12.34567" As String
Dim num1 = 0 As Float
num1 = CNum(str1)
Log(str1)
Log(num1)
Sub CNum(str2cnvrt) As Float
Return str2cnvrt
End Sub