Hello,
Using VS2008, I am adding 2 singles and am getting a bad result. See below
Dim stepsize As Single
Dim temps As Single
Dim startf As Single
dim i as integer
' some code here sets startf to 162.7
' some code here sets stepsize to .01
temps = startf
debug.print (temps.ToString) ' shows "162.7"
Debug.Print(stepsize.ToString) ' shows ".01"
for i = 1 to 11
Debug.Print(temps.ToString)
temps = temps + stepsize
next
Here is the debug output from the loop!!!!
162.7
162.71
162.72
162.73
162.74
162.75
162.76
162.77
162.78
162.7899 <<<< What is this ???
162.7999 <<<<< And this ???
Any insights or fixes???
Thanks,
bartj
Using VS2008, I am adding 2 singles and am getting a bad result. See below
Dim stepsize As Single
Dim temps As Single
Dim startf As Single
dim i as integer
' some code here sets startf to 162.7
' some code here sets stepsize to .01
temps = startf
debug.print (temps.ToString) ' shows "162.7"
Debug.Print(stepsize.ToString) ' shows ".01"
for i = 1 to 11
Debug.Print(temps.ToString)
temps = temps + stepsize
next
Here is the debug output from the loop!!!!
162.7
162.71
162.72
162.73
162.74
162.75
162.76
162.77
162.78
162.7899 <<<< What is this ???
162.7999 <<<<< And this ???
Any insights or fixes???
Thanks,
bartj