Why vb prints out 1??? when d is a double aproximation to 1? shoudnt be 0.99999 or something similar? what if I really need the float value? and how could I print it?
Dim d As Double
For i = 1 To 10
d = d + 0.1
Next
MsgBox(d)
Console.WriteLine(d)
thanks
When using
MsgBoxorConsole.WriteLine,double.ToString()is called in order to convert thedoubleto astring.By default this uses the
Gformat specifier.And:
When converting the infinite
0.9999999....to a string, since it goes forever, rounding occurs, this results in1.A simple test is to run this: