Even though I've been using vba for a while, I've been bad in not declaring my variables which I've been trying to change.
So this code has me puzzled:
I thought I would declare res_rate as a single as double takes more memory and I don't need that precision.
Once I round res_rate I would think regardless if it was a double or single it's value would be permanently changed to one decimal place.</SPAN>
However the above code gives A1 a value of 0.300000011920929 but the debug print prints what I would expect: 0.3
Range("A1") is formatted as general.
When I change the above code and declare res_rate as double then I get what I would expect 0.3 in the debugger and cell A1.
So what am I not seeing? How come after rounding somehow res_rate is retaining the complete decimal value??</SPAN>
So this code has me puzzled:
Code:
Sub test()
Dim res_rate As Single
Dim unique_issues As Integer
Dim headcount As Integer
unique_issues = 6
headcount = 1754
res_rate = Round(unique_issues * 100 / headcount, 1)
Range("A1") = res_rate
Debug.Print res_rate
End Sub
I thought I would declare res_rate as a single as double takes more memory and I don't need that precision.
Once I round res_rate I would think regardless if it was a double or single it's value would be permanently changed to one decimal place.</SPAN>
However the above code gives A1 a value of 0.300000011920929 but the debug print prints what I would expect: 0.3
Range("A1") is formatted as general.
When I change the above code and declare res_rate as double then I get what I would expect 0.3 in the debugger and cell A1.
So what am I not seeing? How come after rounding somehow res_rate is retaining the complete decimal value??</SPAN>