Bob Sawyer

float to double casting issue

Discussion created by Bob Sawyer on May 17, 2006
Latest reply on May 19, 2006 by Bob Sawyer
I am trying to do a calculation where I need to convert a float number to a double to obtain added precision in a chain calculation.  I seem to have encountered a problem.  It appears that the following does not work as expected:
float TestFloat;
double Test;
TestFloat = 20.03564;
Test = (double)TestFloat;
When I look in the debugger, TestFloat shows the correct value.  But, Test shows a value of 20.035642623901367.
If I run the following:
Test = 20.03564;
The debugger shows the exact value as a double.
What is happening?