Hello,
I'm building a detailed physics modeling application and the known rounding errors of the floating-point data types are causing me problems. I've converted my calculations to use Decimal and things have worked out so far. However, in using the Math.Sqrt method (which takes in and returns a Double) I can not convert the return value from a Double to a Decimal without the value being distorted.
Take the following example...
Dim Distance As Double
Distance = System.Math.Sqrt(1000000)
Now "Distance" comes back with "1000" which is good. Now, how can I convert "Distance" to a Decimal? When I use "CDec" or "Convert.ToDecimal" (I assume they are the same) the value comes back as "1000.00000376832D". This has become the bain of my existence...
Any ideas/help?!!!
Thank you!
- Greavis
I'm building a detailed physics modeling application and the known rounding errors of the floating-point data types are causing me problems. I've converted my calculations to use Decimal and things have worked out so far. However, in using the Math.Sqrt method (which takes in and returns a Double) I can not convert the return value from a Double to a Decimal without the value being distorted.
Take the following example...
Dim Distance As Double
Distance = System.Math.Sqrt(1000000)
Now "Distance" comes back with "1000" which is good. Now, how can I convert "Distance" to a Decimal? When I use "CDec" or "Convert.ToDecimal" (I assume they are the same) the value comes back as "1000.00000376832D". This has become the bain of my existence...
Any ideas/help?!!!
Thank you!
- Greavis