I am working on a project where values of up to 10 decimals points are significant.
I am loading values from a binary file, so I am forced to read them in as singles. They are stored in a temporary variable which, for the sake of simplicity, I am calling "mysingle". If certain requirements are fulfilled, that number is passed to a data structure of doubles. Simple enough, right?
However, my value gets changed when it goes from single to double. I wrote some simple code to illustrate this:
Private Sub Command1_Click()
Dim mysingle As Single
Dim mydouble As Double
mysingle = -0.120119
mydouble = mysingle
Debug.Print mydouble
End Sub
If you run this code, you can see that mydouble gets the value of: -0.120118997991085
I've also tried: mydouble=cdbl(mysingle) the results are the same.
Any ideas?
Thanks in advance,
Ryan
I am loading values from a binary file, so I am forced to read them in as singles. They are stored in a temporary variable which, for the sake of simplicity, I am calling "mysingle". If certain requirements are fulfilled, that number is passed to a data structure of doubles. Simple enough, right?
However, my value gets changed when it goes from single to double. I wrote some simple code to illustrate this:
Private Sub Command1_Click()
Dim mysingle As Single
Dim mydouble As Double
mysingle = -0.120119
mydouble = mysingle
Debug.Print mydouble
End Sub
If you run this code, you can see that mydouble gets the value of: -0.120118997991085
I've also tried: mydouble=cdbl(mysingle) the results are the same.
Any ideas?
Thanks in advance,
Ryan