"Th.Krebs" <kl****@hotmail.com> schrieb:
What would u expect as the result of
4.35 * 100.0
435.0 u think ?
well, VB.Net tells us, that the result of this
calculation will be:
4.35*100.0 434.99999999999994 Double
Who is right here, and how can we avoid these kind of miscalculations.
Using Decimal instead of Double?
For the reasons, see:
<URL:http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html>
<URL:http://www.math.grin.edu/~stone/courses/fundamentals/IEEE-reals.html>
<URL:
http://support.microsoft.com/?scid=kb;[LN];42980>
MSDN on 'Decimal':
---
The 'Decimal' value type represents 'Decimal' numbers ranging from positive
79,228,162,514,264,337,593,543,950,335 to negative
79,228,162,514,264,337,593,543,950,335. The 'Decimal' value type is
appropriate for financial calculations requiring large numbers of
significant integral and fractional digits and no round-off errors.
---
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>