doubles

  • Thread starter Thread starter ReneMarxis
  • Start date Start date
Rebe

This is the standard behaviour of floating point values,

If it was not there would probably no decimal values, therefore use that
instead of doubles to solve your problem.

Cor
 
Hi Rene,

Doubles are a non precision floating point number. For precision work with
decimal values use the Decimal type.
If working with Double (or Single) then consider using Round, Ceiling, Floor
etc to. To compare Double values you typically look for a value less than a
margin of error, e.g:


<Runtime.CompilerServices.Extension()> _
Function Approximates(ByVal left As Double, ByVal right As Double,
Optional ByVal maxDifference As Double = 0.000000001) As Boolean
Return Math.Abs(left - right) < maxDifference
End Function
 
Hi Rene,

Doubles are a non precision floating point number.  For precision work with
decimal values use the Decimal type.
If working with Double (or Single) then consider using Round, Ceiling, Floor
etc to.  To compare Double values you typically look for a value less than a
margin of error, e.g:

   <Runtime.CompilerServices.Extension()> _
   Function Approximates(ByVal left As Double, ByVal right As Double,
Optional ByVal maxDifference As Double = 0.000000001) As Boolean
      Return Math.Abs(left - right) < maxDifference
   End Function







- Zitierten Text anzeigen -

Many thanks for your answers. Helped a lot. I ll use decimals as far
as i can starting from now :)
 
Back
Top