ExtendedNumerics.BigDecimal
Arbitrary precision decimal. All operations are exact, except for division.
Division never determines more digits than the given precision.
Based on code by Jan Christoph Bernack (http://stackoverflow.com/a/4524254 or jc.bernack at gmail.com)
Modified and extended by Adam White (https://csharpcodewhisperer.blogspot.com/)
Further modified by Rick Harker, Rick.Rick.Harker@gmail.com
Private Constructor. This one bypasses and check and behavior.
Gets a value that represents the number 0 (zero).
Gets a value that represents the number 1 ().
Gets a value that represents the number 0 (zero).
Gets a value that represents the number 0.5.
Gets a value that represents the number -1 .
Gets a value that represents the number e, also called Euler's number.
Gets a value that represents the number Pi.
Gets a value that represents the number Pi.
Sets the desired precision of all BigDecimal instances, in terms of the number of .
If AlwaysTruncate is set to true all operations are affected.
Specifies whether the significant digits should be truncated to the given precision after each operation.
Setting this to true will tend to accumulate errors at the precision boundary after several arithmetic operations.
Therefore, you should prefer using explicitly when you need it instead,
such st at the end of a series of operations, especially if you are expecting the result to be truncated at the precision length.
This should generally be left disabled by default.
This setting may be useful if you are running into memory or performance issues, as could conceivably be brought on by many operations on irrational numbers.
Specifies whether a call to Normalize is made after every operation and during constructor invocation. The default value is true.
The mantissa of the internal floating point number representation of this BigDecimal.
The exponent of the internal floating point number representation of this BigDecimal.
Gets a number that indicates the sign (negative, positive, or zero) of the current object.
-1 if the value of this object is negative, 0 if the value of this object is zero or 1 if the value of this object is positive.
Gets the number of significant digits in .
Essentially tells you the number of digits in the mantissa.
The length of the BigDecimal value (Equivalent to SignifigantDigits).
Gets the whole-number integer (positive or negative) value of this BigDecimal, so everything to the left of the decimal place.
Equivalent to the Truncate function for a float.
This method returns true if the BigDecimal is equal to zero, false otherwise.
This method returns true if the BigDecimal is greater than zero, false otherwise.
This method returns true if the BigDecimal is less than zero, false otherwise.
Compares the current instance with another object of the same type and returns
an integer that indicates whether the current instance precedes, follows, or
occurs in the same position in the sort order as the other object.
An object to compare with this instance.
A return value of less than zero means this instance precedes obj in the sort order.
A return value of zero means this instance occurs in the same position in the sort order as obj.
A return value of greater than zero means this instance follows obj in the sort order.
Static equality test.
Converts the string representation of a decimal to the BigDecimal equivalent.
Converts the string representation of a decimal to the BigDecimal equivalent.
A string that contains a number to convert.
Converts the string representation of a decimal in a specified culture-specific format to its BigDecimal equivalent.
A string that contains a number to convert.
An object that provides culture-specific formatting information about value.
Tries to convert the string representation of a number to its BigDecimal equivalent, and returns a value that indicates whether the conversion succeeded.
The string representation of a number.
When this method returns, this out parameter contains the BigDecimal equivalent
to the number that is contained in value, or default(BigDecimal) if the conversion fails.
The conversion fails if the value parameter is null or is not of the correct format.
Tries to convert the string representation of a number in a specified style and culture-specific format
to its BigDecimal equivalent, and returns a value that indicates whether the conversion succeeded.
The string representation of a number.
An object that supplies culture-specific formatting information about value.
When this method returns, this out parameter contains the BigDecimal equivalent
to the number that is contained in value, or default(BigDecimal) if the conversion fails.
The conversion fails if the value parameter is null or is not of the correct format.
Removes any trailing zeros on the mantissa, adjusts the exponent, and returns a new .
Returns the zero-based index of the decimal point, if the BigDecimal were rendered as a string.
Returns the whole number integer part of the BigDecimal, dropping anything right of the decimal point. Essentially behaves like Math.Truncate(). For
example, GetWholePart() would return 3 for Math.PI.
Gets the fractional part of the BigDecimal, setting everything left of the decimal point to zero.
Converts to an if possible, otherwise throws .
Converts to an if possible, otherwise throws .
Converts to an if possible, otherwise throws .
Converts to an if possible, otherwise throws .
Converts to an if possible, otherwise throws .
Returns the smaller of two BigDecimal values.
Returns the larger of two BigDecimal values.
Returns the result of multiplying a BigDecimal by negative one.
Adds two BigDecimal values.
Subtracts two BigDecimal values.
Multiplies two BigDecimal values.
Divides two BigDecimal values, returning the remainder and discarding the quotient.
Divides two BigDecimal values.
Returns a specified number raised to the specified power.
Returns a specified number raised to the specified power.
This version uses exponentiation by squaring.
This method should take fewer steps than , and so is used by default
unless is ,
in which case is used as it loses precision slower.
Returns a specified number raised to the specified power.
This version loses precision slower, and so is used when is set to .
Otherwise is used because it is more performant.
Returns a specified number raised to the specified power.
Returns the Nth root of the supplied input decimal to the given number of places.
Returns the number of digits or place values to the left of the decimal point.
Returns the number of digits or place values to the right of the decimal point.
Returns the mantissa of value, aligned to the exponent of reference. Assumes the exponent of value is larger than of reference.
Returns the absolute value of the BigDecimal
Truncates the BigDecimal at the decimal point. Equivalent to using Floor.
Rounds a BigDecimal value to the nearest integral value.
Rounds a BigDecimal value to the nearest integral value. A parameter specifies how to round the value if it is midway between two numbers.
Rounds a BigDecimal to the given number of digits to the right of the decimal point.
Pass a negative precision value to round (zero) digits to the left of the decimal point in a manner that mimics Excel's ROUNDDOWN function.
Rounds a BigDecimal up to the next largest integer value, even if the fractional part is less than one half. Equivalent to obtaining the floor and then adding one.
Rounds a BigDecimal down to the next smallest integer value, even if the fractional part is greater than one half. Equivalent to discarding everything right of the decimal point.
Arbitrary precision sine function.
The input should be the angle in radians.
The input must be restricted to the range of -π/2 <= θ <= π/2.
If your input is negative, just flip the sign.
Arbitrary precision sine function.
The input should be the angle in radians.
The input must be restricted to the range of -π/2 <= θ <= π/2.
If your input is negative, just flip the sign.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision cosine function.
Arbitrary precision cosine function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision tangent function.
The input must not be π/2 or 3π/2, as the tangent is undefined at that value.
Arbitrary precision tangent function.
The input must not be π/2 or 3π/2, as the tangent is undefined at that value.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision cotangent function.
The input must not be zero, as the cotangent is undefined at that value.
Arbitrary precision cotangent function.
The input must not be zero, as the cotangent is undefined at that value.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision secant function.
The input must not be (2*n + 1)*π/2 (an odd multiple of π/2), as the secant is undefined at that value.
Arbitrary precision secant function.
The input must not be (2*n + 1)*π/2 (an odd multiple of π/2), as the secant is undefined at that value.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision cosecant function.
The input must not be zero or π, as the cosecant is undefined at that value.
Arbitrary precision cosecant function.
The input must not be zero or π, as the cosecant is undefined at that value.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision hyperbolic sine function.
Arbitrary precision hyperbolic sine function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision Hyperbolic cosine function.
Arbitrary precision Hyperbolic cosine function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision hyperbolic tangent function.
Arbitrary precision hyperbolic tangent function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision hyperbolic cotangent function.
Arbitrary precision hyperbolic cotangent function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision hyperbolic secant function.
Arbitrary precision hyperbolic secant function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision hyperbolic cosecant function.
The input must not be zero.
Arbitrary precision hyperbolic cosecant function.
The input must not be zero.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision inverse sine function.
Arbitrary precision inverse sine function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision inverse cosine function.
Arbitrary precision inverse cosine function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision inverse tangent function.
Arbitrary precision inverse tangent function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision inverse cotangent function.
Arbitrary precision inverse cotangent function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Arbitrary precision inverse cosecant function.
Arbitrary precision inverse cosecant function.
The argument radians.
The desired precision in terms of the number of digits to the right of the decimal.
Calculates e^x to arbitrary precision.
Calculates e^x to arbitrary precision.
The exponent to raise e to the power of.
The desired precision in terms of the number of digits to the right of the decimal.
Returns the natural logarithm of the input.
The argument to take the natural logarithm of.
Returns the natural logarithm of the input to a specified precision.
The argument to take the natural logarithm of.
The desired precision in terms of the number of digits to the right of the decimal.
Internal implementation of the natural log function to arbitrary precision.
The argument to take the natural logarithm of.
The desired precision in terms of the number of digits to the right of the decimal.
Returns the logarithm of an argument in an arbitrary base.
The base of the logarithm.
The argument to take the logarithm of.
The desired precision in terms of the number of digits to the right of the decimal.
Returns the base-2 logarithm of an argument.
The argument to take the base-2 logarithm of.
The desired precision in terms of the number of digits to the right of the decimal.
Returns the base-10 logarithm of an argument.
The argument to take the base-10 logarithm of.
The desired precision in terms of the number of digits to the right of the decimal.
Allow the BigDecimal to be formatted with the E notation.
Returns the NTHs root of a with .
The root must be greater than or equal to 1 or value must be a positive integer.
ttempt to parse a fraction from a String.
" 1234.45 / 346.456 "
Uncomment this if you want an exception instead of a Boolean.
Calculates a factorial by the divide and conquer method.
This is faster than repeatedly multiplying the next value by a running product
by not repeatedly multiplying by large values.
Essentially, this multiplies every number in the array with its neighbor,
returning an array half as long of products of two numbers.
We then take that array and multiply each pair of values in the array
with its neighbor, resulting in another array half the length of the previous one, and so on...
This results in many multiplications of small, equally sized operands
and only a few multiplications of larger operands.
In the limit, this is more efficient.
The factorial function is used during the calculation of trigonometric functions to arbitrary precision.
Divide the range of numbers to multiply in half recursively.
1
-1
Default to in a sort operation.
Return nulls first in a sort operation.
Return nulls last in a sort operation.
0
Common function to generate the target value to compare against to see if
an operation has reached sufficient precision.
The point of this method instead of having it inline is that we have only
one place to change if we need to increase the value we are adding to
precision to get adjustedPrecision.
Return 1 if radians is an odd multiple of π/2, 0 otherwise.
Calculates a Taylor Series Sum until the specified precision is met.
Based on its parameters, this can approximate several different functions
including the sin, cos, sinh, cosh, and exp trigonometric functions.
The indeterminate value in the Taylor Series that gets multiplied by each term, raised to some
power.
The value to initialize the running total to. Typically, this is either zero or one.
The term number to start the series at. Typically, this is either zero or one.
How much to increment the term index each iteration.
If you want to sum only the even terms, set the counterStart to an even number and this parameter to two.
Each term is multiplied by a variable called sign. By default, sign is equal to 1.
Each iteration, sign is set to sign multiplied by this value.
The point of this is to allow every other term to be negative (so subtracted from the sum) by setting this to
parameter to -1.
Setting this to parameter to -1 will flip the sign of the sign variable every iteration.
Since this gets multiplied by the term, the effect is to flip the sign of every other term.
Set this parameter to 1 if all the terms should remain positive.
A boolean indicating if the denominator of the term should be passed to the factorial function.
Typically, this is true, but sometimes the factorial in the denominator cancels out,
and so we need a way to turn this off.
The required precision to achieve before returning, in terms of the number of correct digits to the right of the
decimal point.
Wraps the input into the range:
-π/2 <= θ <= π/2
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
Looks up a localized string similar to Must be a positive integer..
Looks up a localized string similar to Must be greater than or equal to 1.
Looks up a localized string similar to Argument must be of type {0}.
Looks up a localized string similar to {0} must not equal zero..
Looks up a localized string similar to Negative precision cannot round left of the decimal point more place values than there are whole number digits..
Looks up a localized string similar to The cotangent of π is undefined..
Looks up a localized string similar to The cotangent of zero is undefined..
Looks up a localized string similar to The cosecant of π is undefined..
Looks up a localized string similar to The cosecant of zero is undefined..
Looks up a localized string similar to The hyperbolic cosecant of zero is undefined..
Looks up a localized string similar to The secant of (2*n + 1)*π/2 (an odd multiple of π/2) is undefined..
Looks up a localized string similar to The tangent of 3π/2 is undefined..
Looks up a localized string similar to The tangent of π/2 is undefined..
Looks up a localized string similar to value is not a number (NaN)..
Looks up a localized string similar to Cannot raise zero to a negative power..
Looks up a localized string similar to BigDecimal cannot represent infinity..
Looks up a localized string similar to BigDecimal is too large for a Decimal..
Looks up a localized string similar to BigDecimal is too large for a Double..
Looks up a localized string similar to Couldn't parse numerator or denominator..
Looks up a localized string similar to BigDecimal is too large for a Int32..
Looks up a localized string similar to BigDecimal is too large for a Single..
Looks up a localized string similar to BigDecimal is too large for a UInt32..