I need to convert a string to a double number. The usual double.Parse method returns approximation of the value. As I went through the forum here, I found the solution to be
int precision = 100000;//I want 5 digits after the decimal
double value = exMath.Truncate(double.Parse(STRING) * precision) / precision;
The code works exactly as expected with the Microsoft Emulator, the string “0.03375” yields the value 0,03375. When I run the same code in the ChipworkX, however, I get the value 0,03374. Am i missing something?
I have actually been through this before… However double precision on number smaller than 1 should yield correct for this recursive number. .net has a similar problem with numbers 0 to -1and Microsoft does have a problem with recursive .3333 or .6666. That said we don’t stand much chance do we.
@ Wouter
Yes, I am aware of the way float numbers are stored in the memory. I know an approximation of the number is being stored. What got me wondering is why executing the same code on the emulator and ChipworkX yields different results. After all they are both using NETMF…