Can you explain the stuff below?
I am not sure about internal storage of these numbers.
(Noted that Rnd() returns a Single data type number.)
Code:Sub Test() Dim c As Variant Dim d As Double Dim v As Variant Dim w As Variant v = Rnd Debug.Print TypeName(v), "v = "; Format(v, "0.000000000000000"), "Len(v)="; Len(v) d = v Debug.Print TypeName(d), "d = "; Format(d, "0.000000000000000"), "Len(d)="; Len(d) Debug.Print "v=d : "; (v = d) c = CDec(v) Debug.Print TypeName(c), "c = "; Format(c, "0.000000000000000"), "Len(c)="; Len(c) w = CLng(v * 10 ^ 7) / 10 ^ 7 Debug.Print TypeName(w), "w = "; Format(w, "0.000000000000000"), "Len(w)="; Len(w) Debug.Print "w=v : "; (w = v) Debug.Print End SubCode:Single v = 0.234101400000000 Len(v)= 9 Double d = 0.234101355075836 Len(d)= 8 v=d : True Decimal c = 0.234101400000000 Len(c)= 9 Double w = 0.234101400000000 Len(w)= 9 w=v : False




Reply With Quote