Code: Select all
n := 1.05
MsgBox % Round(n,1)
Code: Select all
n := 1.005
MsgBox % Round(n,2)
Code: Select all
MsgBox % Format("1.05`t{:.52f}`n1.005`t{:.52f}", 1.05, 1.005)
Code: Select all
For Each, x In [1.005, 1.006]
r .= Round(x, 2) " " Format("{:.52f}", x) "`n"
For Each, x In [1.0005, 1.0006]
r .= Round(x, 3) " " Format("{:.52f}", x) "`n"
MsgBox % r
Helgef wrote: ↑08 May 2019, 11:50This is no bug, the result is because the number 1.005 cannot be exactly represented as a float. Instead, 1.005 is stored as something sligthly less. 1.05 cannot either but is stored as something sligthly larger. You can use format to display the float with as many decimal places you like.
Code: Select all
UserInput := 1.075
ClosestValue := Round(UserInput/0.05) * 0.05
Weird, this converter is giving totally different numbers
Users browsing this forum: No registered users and 281 guests