Click or drag to resize

Precision Class

Utilities for working with floating point numbers.
Inheritance Hierarchy
SystemObject
  Altaxo.CalcPrecision

Namespace: Altaxo.Calc
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public static class Precision

The Precision type exposes the following members.

Methods
 NameDescription
Public Extension MethodAlmostEqual(Complex, Complex) Checks whether two Complex numbers are almost equal.
Public Extension MethodAlmostEqual(Complex32, Complex32) Checks whether two Complex numbers are almost equal.
Public Extension MethodAlmostEqual(Double, Double) Checks whether two real numbers are almost equal.
Public Extension MethodAlmostEqual(Single, Single) Checks whether two real numbers are almost equal.
Public Extension MethodAlmostEqual(Complex, Complex, Double) Compares two complex and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqual(Complex, Complex, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqual(Complex32, Complex32, Double) Compares two complex and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqual(Complex32, Complex32, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqual(Double, Double, Double) Compares two doubles and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqual(Double, Double, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqual(Single, Single, Double) Compares two complex and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqual(Single, Single, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqualT(MatrixT, MatrixT, Double) Compares two matrices and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualT(MatrixT, MatrixT, Int32) Compares two matrices and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqualT(VectorT, VectorT, Double) Compares two vectors and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualT(VectorT, VectorT, Int32) Compares two vectors and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqualNorm(Double, Double, Double, Double) Compares two doubles and determines if they are equal within the specified maximum absolute error.
Public Extension MethodAlmostEqualNorm(Double, Double, Double, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqualNormT(T, T, Double) Compares two doubles and determines if they are equal within the specified maximum absolute error.
Public Extension MethodAlmostEqualNormT(T, T, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
Public Extension MethodAlmostEqualNormRelative(Double, Double, Double, Double) Compares two doubles and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualNormRelative(Double, Double, Double, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualNormRelativeT(T, T, Double) Compares two doubles and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualNormRelativeT(T, T, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualNumbersBetween(Double, Double, Int64) Compares two doubles and determines if they are equal to within the tolerance or not. Equality comparison is based on the binary representation.
Public Extension MethodAlmostEqualNumbersBetween(Single, Single, Int32) Compares two floats and determines if they are equal to within the tolerance or not. Equality comparison is based on the binary representation.
Public Extension MethodAlmostEqualRelative(Complex, Complex) Checks whether two Complex numbers are almost equal.
Public Extension MethodAlmostEqualRelative(Complex32, Complex32) Checks whether two Complex numbers are almost equal.
Public Extension MethodAlmostEqualRelative(Double, Double) Checks whether two real numbers are almost equal.
Public Extension MethodAlmostEqualRelative(Single, Single) Checks whether two real numbers are almost equal.
Public Extension MethodAlmostEqualRelative(Complex, Complex, Double) Compares two complex and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualRelative(Complex, Complex, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualRelative(Complex32, Complex32, Double) Compares two complex and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualRelative(Complex32, Complex32, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualRelative(Double, Double, Double) Compares two doubles and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualRelative(Double, Double, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualRelative(Single, Single, Double) Compares two complex and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualRelative(Single, Single, Int32) Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualRelativeT(MatrixT, MatrixT, Double) Compares two matrices and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualRelativeT(MatrixT, MatrixT, Int32) Compares two matrices and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodAlmostEqualRelativeT(VectorT, VectorT, Double) Compares two vectors and determines if they are equal within the specified maximum error.
Public Extension MethodAlmostEqualRelativeT(VectorT, VectorT, Int32) Compares two vectors and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
Public Extension MethodCoerceZero(Double) Forces small numbers near zero to zero.
Public Extension MethodCoerceZero(Double, Double) Forces small numbers near zero to zero, according to the specified absolute accuracy.
Public Extension MethodCoerceZero(Double, Int32) Forces small numbers near zero to zero, according to the specified absolute accuracy.
Public Extension MethodCoerceZero(Double, Int64) Forces small numbers near zero to zero, according to the specified absolute accuracy.
Public Extension MethodCompareTo(Double, Double, Double) Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
Public Extension MethodCompareTo(Double, Double, Int32) Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
Public Extension MethodCompareToNumbersBetween Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
Public Extension MethodCompareToRelative(Double, Double, Double) Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
Public Extension MethodCompareToRelative(Double, Double, Int32) Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
Public Extension MethodDecrement Decrements a floating point number to the next smaller number representable by the data type.
Public Extension MethodEpsilonOf(Double) Evaluates the minimum distance to the next distinguishable number near the argument value.
Public Extension MethodEpsilonOf(Single) Evaluates the minimum distance to the next distinguishable number near the argument value.
Public Extension MethodIncrement Increments a floating point number to the next bigger number representable by the data type.
Public Extension MethodIsFinite Checks if a given double values is finite, i.e. neither NaN nor inifnity
Public Extension MethodIsLarger(Double, Double, Double) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLarger(Double, Double, Int32) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLarger(Single, Single, Double) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLarger(Single, Single, Int32) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLargerNumbersBetween(Double, Double, Int64) Compares two doubles and determines if the first value is larger than the second value to within the tolerance or not. Equality comparison is based on the binary representation.
Public Extension MethodIsLargerNumbersBetween(Single, Single, Int64) Compares two doubles and determines if the first value is larger than the second value to within the tolerance or not. Equality comparison is based on the binary representation.
Public Extension MethodIsLargerRelative(Double, Double, Double) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLargerRelative(Double, Double, Int32) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLargerRelative(Single, Single, Double) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsLargerRelative(Single, Single, Int32) Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmaller(Double, Double, Double) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmaller(Double, Double, Int32) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmaller(Single, Single, Double) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmaller(Single, Single, Int32) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmallerNumbersBetween(Double, Double, Int64) Compares two doubles and determines if the first value is smaller than the second value to within the tolerance or not. Equality comparison is based on the binary representation.
Public Extension MethodIsSmallerNumbersBetween(Single, Single, Int64) Compares two doubles and determines if the first value is smaller than the second value to within the tolerance or not. Equality comparison is based on the binary representation.
Public Extension MethodIsSmallerRelative(Double, Double, Double) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmallerRelative(Double, Double, Int32) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmallerRelative(Single, Single, Double) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodIsSmallerRelative(Single, Single, Int32) Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
Public Extension MethodListAlmostEqual(IListComplex32, IListComplex32, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListComplex32, IListComplex32, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListDouble, IListDouble, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListDouble, IListDouble, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListComplex, IListComplex, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListComplex, IListComplex, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListSingle, IListSingle, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqual(IListSingle, IListSingle, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualNormT Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualNormRelativeT Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListComplex32, IListComplex32, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListComplex32, IListComplex32, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListDouble, IListDouble, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListDouble, IListDouble, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListComplex, IListComplex, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListComplex, IListComplex, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListSingle, IListSingle, Double) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodListAlmostEqualRelative(IListSingle, IListSingle, Int32) Compares two lists of doubles and determines if they are equal within the specified maximum error.
Public Extension MethodMagnitude(Double) Returns the magnitude of the number.
Public Extension MethodMagnitude(Single) Returns the magnitude of the number.
Public Extension MethodMaximumMatchingFloatingPointNumber Returns the floating point number that will match the value with the tolerance on the maximum size (i.e. the result is always bigger than the value)
Public Extension MethodMinimumMatchingFloatingPointNumber Returns the floating point number that will match the value with the tolerance on the minimum size (i.e. the result is always smaller than the value)
Public Extension MethodNumbersBetween Evaluates the count of numbers between two double numbers
Public Extension MethodPositiveEpsilonOf(Double) Evaluates the minimum distance to the next distinguishable number near the argument value.
Public Extension MethodPositiveEpsilonOf(Single) Evaluates the minimum distance to the next distinguishable number near the argument value.
Public Extension MethodRangeOfMatchingFloatingPointNumbers Determines the range of floating point numbers that will match the specified value with the given tolerance.
Public Extension MethodRangeOfMatchingNumbers Determines the range of ulps that will match the specified value with the given tolerance.
Public Extension MethodCode exampleRound(BigInteger, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(Decimal, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(Double, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(Int16, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(Int32, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(Int64, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(Single, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(UInt16, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(UInt32, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodCode exampleRound(UInt64, Int32) Round to the number closest to 10^(-decimals). Negative decimals to round within the integer part.
Public Extension MethodRoundToMultiple(Decimal, Decimal) Round to a multiple of the provided positive basis.
Public Extension MethodRoundToMultiple(Double, Double) Round to a multiple of the provided positive basis.
Public Extension MethodRoundToMultiple(Single, Single) Round to a multiple of the provided positive basis.
Public Extension MethodRoundToPower(Double, Double) Round to a multiple of the provided positive basis.
Public Extension MethodRoundToPower(Single, Single) Round to a multiple of the provided positive basis.
Public Extension MethodScaleUnitMagnitude Returns the number divided by it's magnitude, effectively returning a number between -10 and 10.
Top
Fields
 NameDescription
Public fieldStatic memberDoubleDecimalPlaces The number of significant decimal places of double-precision floating numbers (64 bit).
Public fieldStatic memberDoublePrecision Standard epsilon, the maximum relative precision of IEEE 754 double-precision floating numbers (64 bit). According to the definition of Prof. Demmel and used in LAPACK and Scilab.
Public fieldStatic memberMachineEpsilon Actual double precision machine epsilon, the smallest number that can be subtracted from 1, yielding a results different than 1. This is also known as unit roundoff error. According to the definition of Prof. Demmel. On a standard machine this is equivalent to `DoublePrecision`.
Public fieldStatic memberPositiveDoublePrecision Standard epsilon, the maximum relative precision of IEEE 754 double-precision floating numbers (64 bit). According to the definition of Prof. Higham and used in the ISO C standard and MATLAB.
Public fieldStatic memberPositiveMachineEpsilon Actual double precision machine epsilon, the smallest number that can be added to 1, yielding a results different than 1. This is also known as unit roundoff error. According to the definition of Prof. Higham. On a standard machine this is equivalent to `PositiveDoublePrecision`.
Public fieldStatic memberPositiveSinglePrecision Standard epsilon, the maximum relative precision of IEEE 754 single-precision floating numbers (32 bit). According to the definition of Prof. Higham and used in the ISO C standard and MATLAB.
Public fieldStatic memberSingleDecimalPlaces The number of significant decimal places of single-precision floating numbers (32 bit).
Public fieldStatic memberSinglePrecision Standard epsilon, the maximum relative precision of IEEE 754 single-precision floating numbers (32 bit). According to the definition of Prof. Demmel and used in LAPACK and Scilab.
Top
Remarks

Useful links:

  • http://docs.sun.com/source/806-3568/ncg_goldberg.html#689 - What every computer scientist should know about floating-point arithmetic
  • http://en.wikipedia.org/wiki/Machine_epsilon - Gives the definition of machine epsilon

See Also