BigFloat Class

Represents a floating-point number with arbitrary precision.

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
[SerializableAttribute]
public class BigFloat : IComparable, IFormattable, 
	IEquatable<BigFloat>, IComparable<BigFloat>
Inheritance
Object  →  BigFloat
Implements
IComparable, IComparable<BigFloat>, IEquatable<BigFloat>, IFormattable

Remarks

Use the BigFloat class to represent numbers that may not fit into the standard single or double precision floating point types, or the decimal type.

A BigFloat can have a precision of up to 236 bits. The binary exponent is an integer, which allows a decimal exponent up to roughly 646 million. This gives the BigFloat type a total range of roughly

BigFloat numbers can be constructed in a variety of ways, including from other numerical types and from strings. Implicit (widening) conversions are available for all built-in integer types and floating-point types. Explicit conversions are also available for Decimal and BigRational.

The BigFloat class provides methods for all the common operations on real numbers. Overloaded versions of the major arithmetic operators are provided for languages that support them. For languages that don't support operator overloading, equivalent static methods are supplied.

The precision of the result of an operation depends on the operation itself. Addition and subtraction by default use the smallest absolute precision of their operands. Multiplication and division use the smallest relative precision of their operands. Details on the precision of specific operations can be found in the documentation.

Results are rounded to the nearest number. There is a high probability but no guarantee that the result is correctly rounded.

The desired precision and rounding mode can be overridden by passing additional arguments to the method that performs the operation. An AccuracyGoal value specifies the precision. The precision can be absolute or relative. By default, the precision is inherited from the operands. The RoundingMode determines how the result is rounded.

The BigFloat type supports generic arithmetic. The associated arithmetic type implements IIeeeOperations<T>, which means it supports all methods available for Double in the Math class, as well as special values such as PositiveInfinity, NegativeInfinity and NaN.

Constructors

BigFloat(BigInteger) Constructs a new arbitrary precision floating-point number from a BigInteger.
BigFloat(BigRational) Constructs a new arbitrary precision floating-point number from a rational number.
BigFloat(Double) Constructs a new arbitrary precision floating-point number from a double-precision floating-point number.
BigFloat(Int32) Constructs a new arbitrary precision floating-point number from an integer.
BigFloat(Int64) Constructs a new arbitrary precision floating-point number from an integer.
BigFloat(Double, AccuracyGoal) Constructs a new arbitrary precision floating-point number from a double-precision floating-point number.
BigFloat(Int32, AccuracyGoal) Constructs a new arbitrary precision floating-point number from an integer.
BigFloat(Int64, AccuracyGoal) Constructs a new arbitrary precision floating-point number from an integer.
BigFloat(BigInteger, AccuracyGoal, RoundingMode) Constructs a new arbitrary precision floating-point number from a BigInteger.
BigFloat(BigRational, AccuracyGoal, RoundingMode) Constructs a new arbitrary precision floating-point number from a rational number.
BigFloat(Int32, BigInteger, Int32) Constructs a new arbitrary precision floating-point number from the specified sign, mantissa, and exponent.

Properties

AbsoluteBinaryPrecision Gets the number of stored bits in the fractional part of the number.
BinaryPrecision Gets the number of bits of precision used to store the number.
DefaultAccuracyGoal Gets or sets the default accuracy goal when performing operations on existing BigFloat numbers.
DefaultRoundingMode Gets or sets the default rounding mode.
Exponent Gets the exponent part of the BigFloat value.
InitialAccuracyGoal Gets or sets the default accuracy goal when constructing new BigFloat numbers.
IsInteger Checks if the value of a BigFloat value is an integer.
IsNegativeZero Checks if the value of a BigFloat value is negative zero.
IsOne Checks if the value of a BigFloat value is equal to one.
IsZero Checks if the value of a BigFloat value is zero.
Mantissa Gets the mantissa part of the BigFloat value.
Sign Gets the sign of the BigFloat value.

Methods

Abs Returns the absolute value of a number.
Acos(BigFloat) Returns the inverse cosine of a number.
Acos(BigFloat, AccuracyGoal) Returns the inverse cosine of a number with the specified accuracy.
Acos(BigFloat, AccuracyGoal, RoundingMode) Returns the inverse cosine of a number with the specified accuracy.
Acosh(BigFloat) Returns the inverse hyperbolic cosine of a number.
Acosh(BigFloat, AccuracyGoal) Returns the inverse hyperbolic cosine of a number with the specified accuracy.
Acosh(BigFloat, AccuracyGoal, RoundingMode) Returns the inverse hyperbolic cosine of a number with the specified accuracy.
Add(BigFloat, BigFloat) Adds two BigFloat numbers.
Add(BigFloat, BigFloat, AccuracyGoal) Adds two numbers and returns the result with the specified accuracy.
Add(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Adds two numbers and returns the result with the specified accuracy.
Asin(BigFloat) Returns the inverse sine of a number.
Asin(BigFloat, AccuracyGoal) Returns the inverse sine of a number with the specified accuracy.
Asin(BigFloat, AccuracyGoal, RoundingMode) Returns the inverse sine of a number with the specified accuracy.
Asinh(BigFloat) Returns the inverse hyperbolic sine of a number.
Asinh(BigFloat, AccuracyGoal) Returns the inverse hyperbolic sine of a number with the specified accuracy.
Asinh(BigFloat, AccuracyGoal, RoundingMode) Returns the inverse hyperbolic sine of a number with the specified accuracy.
Atan(BigFloat) Returns the inverse tangent of a number.
Atan(BigFloat, AccuracyGoal) Returns the inverse tangent of a number with the specified accuracy.
Atan(BigFloat, AccuracyGoal, RoundingMode) Returns the inverse tangent of a number with the specified accuracy.
Atan2(BigFloat, BigFloat) Returns the inverse tangent of a number.
Atan2(BigFloat, BigFloat, AccuracyGoal) Returns the inverse tangent of a number with the specified accuracy.
Atan2(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Returns the inverse tangent of a number with the specified accuracy.
Atanh(BigFloat) Returns the inverse hyperbolic tangent of a number.
Atanh(BigFloat, AccuracyGoal) Returns the inverse hyperbolic tangent of a number with the specified accuracy.
Atanh(BigFloat, AccuracyGoal, RoundingMode) Returns the inverse hyperbolic tangent of a number with the specified accuracy.
Ceiling Rounds a number up to the nearest integer.
Compare Compares two BigFloat numbers up to the specified AccuracyGoal.
CompareTo(BigFloat) Compares a number to another number.
CompareTo(BigFloat, AccuracyGoal) Compares a number to another number up to the specified AccuracyGoal.
CopySign Copies the sign of a number to another number.
Cos(BigFloat) Returns the cosine of an angle.
Cos(BigFloat, AccuracyGoal) Returns the cosine of an angle with the specified accuracy.
Cos(BigFloat, AccuracyGoal, RoundingMode) Returns the cosine of an angle with the specified accuracy.
Cosh(BigFloat) Returns the hyperbolic cosine of a number.
Cosh(BigFloat, AccuracyGoal) Returns the hyperbolic cosine of a number with the specified accuracy.
Cosh(BigFloat, AccuracyGoal, RoundingMode) Returns the hyperbolic cosine of a number with the specified accuracy.
Divide(BigFloat, BigFloat) Divides one BigFloat by another.
Divide(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Divides one BigFloat by another to the specified accuracy.
Equals(BigFloat) Tests whether a number equals another number.
Equals(Object) Returns a value indicating whether this instance is equal to a specified object.
(Overrides Object.Equals(Object))
Equals(BigFloat, AccuracyGoal) Tests whether a number equals another number up to the specified AccuracyGoal.
Equals(BigFloat, BigFloat, AccuracyGoal) Tests whether a number equals another number up to the specified AccuracyGoal.
Exp(BigFloat) Returns e raised to the specified power.
Exp(BigFloat, AccuracyGoal) Returns e raised to the specified power to the specified accuracy.
Exp(BigFloat, AccuracyGoal, RoundingMode) Returns e raised to the specified power to the specified accuracy.
Expm1 Returns e raised to the specified power to the specified accuracy.
ExtendPrecision Returns a BigFloat value with at least the specified precision and the same value as this instance.
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Floor Rounds a number down to the nearest integer.
FractionalPart Returns the fractional part of the BigFloat number.
FromRational Constructs a new arbitrary precision floating-point number from a rational number.
Gamma(BigFloat) Returns the gamma function of a number.
Gamma(BigFloat, AccuracyGoal) Returns the gamma function of a number to the specified accuracy.
Gamma(BigFloat, AccuracyGoal, RoundingMode) Returns the gamma function of a number to the specified accuracy.
GetDecimalDigits Gets the approximate number of decimal digits in the BigFloat value.
GetHashCode Returns the hash code for this instance.
(Overrides Object.GetHashCode())
GetPi(AccuracyGoal) Returns the value of pi to the specified number of digits.
GetPi(AccuracyGoal, RoundingMode) Returns the value of pi to the specified number of digits.
GetTypeGets the Type of the current instance.
(Inherited from Object)
Inverse(BigFloat) Returns the reciprocal of a number.
Inverse(BigFloat, AccuracyGoal) Returns the reciprocal of a number with the specified accuracy.
Inverse(BigFloat, AccuracyGoal, RoundingMode) Returns the reciprocal of a number with the specified accuracy.
IsInfinity Checks if the value of a BigFloat value is infinite.
IsNaN Checks if the value of a BigFloat value is "Not a Number."
IsNegativeInfinity Checks if the value of a BigFloat value is negative infinity.
IsPositiveInfinity Checks if the value of a BigFloat value is positive infinity.
Log(BigFloat) Returns the natural logarithm of a number with the specified accuracy.
Log(BigFloat, AccuracyGoal) Returns the natural logarithm of a number with the specified accuracy.
Log(BigFloat, BigFloat) Returns the logarithm of a number relative to the specified base with the specified accuracy.
Log(BigFloat, AccuracyGoal, RoundingMode) Returns the natural logarithm of a number with the specified accuracy.
Log(BigFloat, BigFloat, AccuracyGoal) Returns the logarithm of a number relative to the specified base with the specified accuracy.
Log(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Returns the logarithm of a number relative to the specified base with the specified accuracy.
Log1PlusX(BigFloat) Returns the natural logarithm of 1 plus a number with the default accuracy.
Log1PlusX(BigFloat, AccuracyGoal) Returns the natural logarithm of 1 plus a number with the specified accuracy.
Log1PlusX(BigFloat, AccuracyGoal, RoundingMode) Returns the natural logarithm of 1 plus a number with the specified accuracy.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Modulus Returns the remainder after dividing one BigFloat number by another.
Multiply(BigFloat, BigFloat) Multiplies two numbers.
Multiply(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Multiplies two numbers and returns the result to the specified accuracy.
Negate Returns a BigFloat value with the opposite sign.
Parse(String) Converts a string value to a BigFloat.
Parse(String, AccuracyGoal) Converts a string value to a BigFloat.
Parse(String, NumberStyles) Converts a string value to a BigFloat.
Parse(String, IFormatProvider) Converts a string value to a BigFloat.
Parse(String, AccuracyGoal, NumberStyles) Converts a string value to a BigFloat.
Parse(String, AccuracyGoal, IFormatProvider) Converts a string value to a BigFloat.
Parse(String, NumberStyles, IFormatProvider) Converts a string value to a BigFloat.
Parse(String, AccuracyGoal, NumberStyles, IFormatProvider) Converts a string value to a BigFloat.
Pow(BigFloat, BigFloat) Raises a number to the specified power.
Pow(BigFloat, Int32) Raises a number to the specified power.
Pow(BigFloat, BigFloat, AccuracyGoal) Raises a number to the specified power with the specified accuracy.
Pow(BigFloat, Int32, AccuracyGoal) Raises a number to the specified power with the specified accuracy.
Pow(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Raises a number to the specified power with the specified accuracy.
Pow(BigFloat, Int32, AccuracyGoal, RoundingMode) Raises a number to the specified power with the specified accuracy.
RestrictPrecision Returns a BigFloat value with at most the specified precision and the same value as this instance.
Root(BigFloat, Int32) Returns the square root of a number.
Root(BigFloat, Int32, AccuracyGoal) Returns the specified root of a number with the specified accuracy.
Root(BigFloat, Int32, AccuracyGoal, RoundingMode) Returns the specified root of a number with the specified accuracy.
Round(BigFloat) Rounds a BigFloat value to the nearest integer.
Round(BigFloat, Int32) Rounds a BigFloat value to the specified number of decimal digits.
Round(BigFloat, Int32, RoundingMode) Rounds a BigFloat value to the specified number of decimal digits.
ScaleByPowerOfTwo Multiplies a BigFloat value by a power of two.
Sin(BigFloat) Returns the sine of an angle.
Sin(BigFloat, AccuracyGoal) Returns the sine of an angle with the specified accuracy.
Sin(BigFloat, AccuracyGoal, RoundingMode) Returns the sine of an angle with the specified accuracy.
SinCos(BigFloat) Calculates the sine and the cosine of an angle.
SinCos(BigFloat, AccuracyGoal) Calculates the sine and the cosine of an angle with the specified accuracy.
SinCos(BigFloat, AccuracyGoal, RoundingMode) Calculates the sine and the cosine of an angle with the specified accuracy.
SinCos(BigFloat, BigFloat, BigFloat) Calculates the sine and the cosine of an angle.
SinCos(BigFloat, AccuracyGoal, BigFloat, BigFloat) Calculates the sine and the cosine of an angle with the specified accuracy.
SinCos(BigFloat, AccuracyGoal, RoundingMode, BigFloat, BigFloat) Calculates the sine and the cosine of an angle with the specified accuracy.
Sinh(BigFloat) Returns the hyperbolic sine of a number.
Sinh(BigFloat, AccuracyGoal) Returns the hyperbolic sine of a number with the specified accuracy.
Sinh(BigFloat, AccuracyGoal, RoundingMode) Returns the hyperbolic sine of a number with the specified accuracy.
Sqrt(BigFloat) Returns the square root of a number.
Sqrt(BigFloat, AccuracyGoal) Returns the square root of a number with the specified accuracy.
Sqrt(BigFloat, AccuracyGoal, RoundingMode) Returns the square root of a number with the specified accuracy.
Subtract(BigFloat, BigFloat) Subtracts one number from another.
Subtract(BigFloat, BigFloat, AccuracyGoal, RoundingMode) Subtracts one number from another and returns the result to the specified accuracy.
Tan(BigFloat) Returns the tangent of an angle.
Tan(BigFloat, AccuracyGoal) Returns the tangent of an angle with the specified accuracy.
Tan(BigFloat, AccuracyGoal, RoundingMode) Returns the tangent of an angle with the specified accuracy.
Tanh(BigFloat) Returns the hyperbolic tangent of a number.
Tanh(BigFloat, AccuracyGoal) Returns the hyperbolic tangent of a number with the specified accuracy.
Tanh(BigFloat, AccuracyGoal, RoundingMode) Returns the hyperbolic tangent of a number with the specified accuracy.
ToString() Returns a String representation of the number.
(Overrides Object.ToString())
ToString(IFormatProvider) Formats the value of the current instance using the specified format.
ToString(String) Formats the value of the current instance using the specified format.
ToString(String, IFormatProvider) Formats the value of the current instance using the specified format.
TryParse(String, BigFloat) Attempts to convert a string value to a BigFloat.
TryParse(String, AccuracyGoal, BigFloat) Attempts to convert a string value to a BigFloat.
TryParse(String, AccuracyGoal, NumberStyles, IFormatProvider, BigFloat) Attempts to convert a string value to a BigFloat.

Operators

Addition(BigFloat, BigFloat) Adds two BigFloat numbers.
Addition(BigFloat, BigInteger) Adds a BigFloat number and a BigInteger.
Addition(BigFloat, BigRational) Adds a BigFloat and a BigRational number.
Addition(BigFloat, Int32) Adds two BigFloat numbers.
Addition(BigInteger, BigFloat) Adds a BigFloat number and a BigInteger.
Addition(BigRational, BigFloat) Adds a BigFloat and a BigRational number.
Addition(Int32, BigFloat) Adds two BigFloat numbers.
Division(BigFloat, BigFloat) Divides one BigFloat by another.
Division(BigFloat, BigInteger) Divides two numbers.
Equality(BigFloat, BigFloat) Returns whether a BigFloat is equal to another.
Explicit(BigFloat to BigInteger) Converts a BigFloat to a BigInteger.
Explicit(BigFloat to Quad) Converts a BigFloat value to a Double.
Explicit(BigFloat to Byte) Converts a BigFloat to a Byte value.
Explicit(BigFloat to Decimal) Converts a BigFloat to a Decimal number.
Explicit(BigFloat to Double) Converts a BigFloat value to a Double.
Explicit(BigFloat to Int16) Converts a BigFloat to a Int16 value.
Explicit(BigFloat to Int32) Converts a BigFloat to a Int32 value.
Explicit(BigFloat to Int64) Converts a BigFloat to a long integer.
Explicit(BigFloat to SByte) Converts a BigFloat to a SByte value.
Explicit(BigFloat to Single) Converts a BigFloat to a single-precision floating-point number.
Explicit(BigFloat to UInt16) Converts a BigFloat to a UInt16 value.
Explicit(BigFloat to UInt32) Converts a BigFloat to an unsigned integer.
Explicit(BigFloat to UInt64) Converts a BigFloat to a long unsigned integer.
Exponent(BigFloat, BigFloat) Represents the exponentiation operator.
Exponent(BigFloat, Int32) Represents the exponentiation operator.
Exponentiation(BigFloat, BigFloat) Represents the exponentiation operator.
Exponentiation(BigFloat, Int32) Represents the exponentiation operator.
GreaterThan(BigFloat, BigFloat) Returns whether a BigFloat is greater than another.
GreaterThanOrEqual(BigFloat, BigFloat) Returns whether a BigFloat is greater than or equal to another.
Implicit(BigInteger to BigFloat) Converts a BigInteger to a BigFloat value.
Implicit(Byte to BigFloat) Converts a BigInteger value to a Byte value.
Implicit(Decimal to BigFloat) Converts a Decimal number to a BigFloat value.
Implicit(Double to BigFloat) Converts a double-precision floating-point number to a BigInteger value.
Implicit(Int16 to BigFloat) Converts a 16 bit signed integer to a BigFloat value.
Implicit(Int32 to BigFloat) Converts a 32 bit signed integer to a BigFloat value.
Implicit(Int64 to BigFloat) Converts a 64 bit signed integer to a BigFloat value.
Implicit(SByte to BigFloat) Converts a signed byte to a BigFloat value.
Implicit(Single to BigFloat) Converts a single-precision floating-point number to a BigInteger value.
Implicit(UInt16 to BigFloat) Converts a 16 bit unsigned integer to a BigFloat value.
Implicit(UInt32 to BigFloat) Converts a 32 bit unsigned integer to a BigFloat value.
Implicit(UInt64 to BigFloat) Converts a 64 bit unsigned integer to a BigFloat value.
Inequality(BigFloat, BigFloat) Returns whether a BigFloat is not equal to another.
LessThan(BigFloat, BigFloat) Returns whether a BigFloat is less than another.
LessThanOrEqual(BigFloat, BigFloat) Returns whether a BigFloat is less than or equal to another.
Modulus(BigFloat, BigFloat) Returns the remainder after dividing one BigFloat number by another.
Multiply(BigFloat, BigFloat) Multiplies two numbers.
Multiply(BigFloat, BigInteger) Multiplies two numbers.
Multiply(BigInteger, BigFloat) Multiplies two numbers.
Multiply(Int32, BigFloat) Multiplies a BigFloat value by an integer.
Subtraction(BigFloat, BigFloat) Subtracts one number from another.
Subtraction(BigFloat, Int32) Adds two BigFloat numbers.
Subtraction(Int32, BigFloat) Adds two BigFloat numbers.
UnaryNegation(BigFloat) Returns a BigInteger value with the opposite sign.

Fields

MaxValue The largest possible BigFloat,
MinPositiveValue The smallest BigFloat greater than zero,
MinusOne The number -1 as a BigFloat,
MinValue The smallest possible BigFloat,
NaN Not-a-Number, the value returned when the result is undefined.
NegativeInfinity Negative infinity as a BigFloat,
NegativeZero Negative 0 as a BigFloat,
One The number 1 as a BigFloat,
PositiveInfinity Positive infinity as a BigFloat,
Zero The number 0 as a BigFloat,

See Also