PeterO.Numbers.EDecimal
## PeterO.Numbers.EDecimal
public sealed class EDecimal : System.IComparable, System.IEquatable
Represents an arbitrary-precision decimal floating-point number. (The “E” stands for “extended”, meaning that instances of this class can be values other than numbers proper, such as infinity and not-a-number.) About decimal arithmetic
Decimal (base-10) arithmetic, such as that provided by this class, is appropriate for calculations involving such real-world data as prices and other sums of money, tax rates, and measurements. These calculations often involve multiplying or dividing one decimal with another decimal, or performing other operations on decimal numbers. Many of these calculations also rely on rounding behavior in which the result after rounding is an arbitrary-precision decimal number (for example, multiplying a price by a premium rate, then rounding, should result in a decimal amount of money).
On the other hand, most implementations of float
and double
, including in C# and Java, store numbers in a binary (base-2) floating-point format and use binary floating-point arithmetic. Many decimal numbers can’t be represented exactly in binary floating-point format (regardless of its length). Applying binary arithmetic to numbers intended to be decimals can sometimes lead to unintuitive results, as is shown in the description for the FromDouble() method of this class.
About EDecimal instances
Each instance of this class consists of an integer significand and an integer exponent, both arbitrary-precision. The value of the number equals significand * 10^exponent.
The significand is the value of the digits that make up a number, ignoring the decimal point and exponent. For example, in the number 2356.78, the significand is 235678. The exponent is where the “floating” decimal point of the number is located. A positive exponent means “move it to the right”, and a negative exponent means “move it to the left.” In the example 2, 356.78, the exponent is -2, since it has 2 decimal places and the decimal point is “moved to the left by 2.” Therefore, in the arbitrary-precision decimal representation, this number would be stored as 235678 * 10^-2.
The significand and exponent format preserves trailing zeros in the number’s value. This may give rise to multiple ways to store the same value. For example, 1.00 and 1 would be stored differently, even though they have the same value. In the first case, 100 * 10^-2 (100 with decimal point moved left by 2), and in the second case, 1 * 10^0 (1 with decimal point moved 0).
This class also supports values for negative zero, not-a-number (NaN) values, and infinity. Negative zero is generally used when a negative number is rounded to 0; it has the same mathematical value as positive zero. Infinity is generally used when a nonzero number is divided by zero, or when a very high or very low number can’t be represented in a given exponent range. Not-a-number is generally used to signal errors.
This class implements the General Decimal Arithmetic Specification version 1.70 except part of chapter 6( http://speleotrove.com/decimal/decarith.html
).
Errors and Exceptions
Passing a signaling NaN to any arithmetic operation shown here will signal the flag FlagInvalid and return a quiet NaN, even if another operand to that operation is a quiet NaN, unless the operation’s documentation expressly states that another result happens when a signaling NaN is passed to that operation.
Passing a quiet NaN to any arithmetic operation shown here will return a quiet NaN, unless the operation’s documentation expressly states that another result happens when a quiet NaN is passed to that operation. Invalid operations will also return a quiet NaN, as stated in the individual methods.
Unless noted otherwise, passing a null arbitrary-precision decimal argument to any method here will throw an exception.
When an arithmetic operation signals the flag FlagInvalid, FlagOverflow, or FlagDivideByZero, it will not throw an exception too, unless the flag’s trap is enabled in the arithmetic context (see EContext’s Traps property).
If an operation requires creating an intermediate value that might be too big to fit in memory (or might require more than 2 gigabytes of memory to store – due to the current use of a 32-bit integer internally as a length), the operation may signal an invalid-operation flag and return not-a-number (NaN). In certain rare cases, the CompareTo method may throw OutOfMemoryException (called OutOfMemoryError in Java) in the same circumstances.
Serialization
An arbitrary-precision decimal value can be serialized (converted to a stable format) in one of the following ways:
-
By calling the toString() method, which will always return distinct strings for distinct arbitrary-precision decimal values.
-
By calling the UnsignedMantissa, Exponent, and IsNegative properties, and calling the IsInfinity, IsQuietNaN, and IsSignalingNaN methods. The return values combined will uniquely identify a particular arbitrary-precision decimal value.
Thread safety
Instances of this class are immutable, so they are inherently safe for use by multiple threads. Multiple instances of this object with the same properties are interchangeable, so they should not be compared using the “==” operator (which might only check if each side of the operator is the same instance).
Comparison considerations
This class’s natural ordering (under the CompareTo method) is not consistent with the Equals method. This means that two values that compare as equal under the CompareTo method might not be equal under the Equals method. The CompareTo method compares the mathematical values of the two instances passed to it (and considers two different NaN values as equal), while two instances with the same mathematical value, but different exponents, will be considered unequal under the Equals method.
Security note
It is not recommended to implement security-sensitive algorithms using the methods in this class, for several reasons:
-
EDecimal
objects are immutable, so they can’t be modified, and the memory they occupy is not guaranteed to be cleared in a timely fashion due to garbage collection. This is relevant for applications that use many-digit-long numbers as secret parameters. -
The methods in this class (especially those that involve arithmetic) are not guaranteed to be “constant-time” (nondata-dependent) for all relevant inputs. Certain attacks that involve encrypted communications have exploited the timing and other aspects of such communications to derive keying material or cleartext indirectly.
Applications should instead use dedicated security libraries to handle big numbers in security-sensitive algorithms.
Reproducibility note
Some applications, such as simulations, care about results that are reproducible, bit for bit, across computers and across runs of the application. Bruce Dawson, in “Floating-Point Determinism” ( https://randomascii.wordpress.com/
2013/07/16/floating-point-determinism/
), identified many reproducibility issues with floating-point numbers, and here is how they relate to the EDecimal and EFloat classes of this library:
-
Runtime floating-point settings: All the settings that change how EDecimal and EFloat behave are given as parameters to the appropriate methods, especially via EContext objects, which specify the precision, rounding, and exponent range of numbers, among other things. The EDecimal and EFloat classes avoid the use of “native” floating-point data types (except for methods that convert to or from
float
,double
, orSystem.Decimal
). Such “native” types are often subject to runtime settings that change how floating-point math behaves with them, and these settings are often not accessible to .NET or Java code. -
Nonassociativity and intermediate precisions: In general, EDecimal and EFloat use “unlimited” precision in their calculations unless specified otherwise by an EContext object. However, by limiting the precision of EDecimal, EFloat, and other floating-point numbers in this way, operations such as addition and multiplication on three or more numbers can be nonassociative , meaning the result can change depending on the order in which those numbers are added or multiplied. This property means that if an algorithm does not ensure such numbers are added or multiplied in the same order every time, its results may not be reproducible across computers or across runs of the application. This nonassociativity problem can happen, for example, if an application splits a calculation across several threads and combines their results in the end. The problems with an unspecified order of operations (in the same line of code) and intermediate precisions (problems present in C and C++, for example) don’t exist with method calls to EDecimal and EFloat methods, especially since they require limited-precision support to be declared explicitly via EContext.
-
fmadd instruction: EDecimal and EFloat include a MultiplyAndAdd method with the same semantics as in the General Decimal Arithmetic Specification, which requires delivering correctly rounded results for this method.
-
Square root estimate: Not applicable since EDecimal and EFloat don’t include any estimates to square root.
-
Transcendental functions: This includes logarithms, exponentials, and the Pi method. For these functions, results are not guaranteed to always be correctly rounded. When using transcendentals, an application that cares about reproducibility should choose one version of this library and stick to it; this at least has the advantage that the implementation will be the same across computers, unlike with “native” floating-point types where the choice of implementation is often not within the application’s control.
-
Conversions: Conversions between EDecimal or EFloat and text strings have the same implementation across computers for the same version of this library (see also the advice for transcendentals above). But as for the ToDouble, ToSingle, FromDouble, and FromSingle methods, note that some implementations of Java and.NET may or may not support preserving the value of subnormal numbers (numbers other than zero with the lowest possible exponent) or the payloads held in a not-a-number (NaN) value of float or double; thus these methods should not be considered reproducible across computers.
-
Compiler differences: Not applicable where these classes don’t use “native” floating-point types.
-
Uninitialized data; per-processor code: Not applicable.
Forms of numbers
There are several other types of numbers that are mentioned in this class and elsewhere in this documentation. For reference, they are specified here.
Unsigned integer : An integer that’s always 0 or greater, with the following maximum values:
-
8-bit unsigned integer, or byte : 255.
-
16-bit unsigned integer: 65535.
-
32-bit unsigned integer: (2 32 -1).
-
64-bit unsigned integer: (2 64 -1).
Signed integer : An integer in two’s-complement form , with the following ranges:
-
8-bit signed integer: -128 to 127.
-
16-bit signed integer: -32768 to 32767.
-
32-bit signed integer: -2 31 to (2 31 - 1).
-
64-bit signed integer: -2 63 to (2 63 - 1).
Two’s complement form : In two’s-complement form , nonnegative numbers have the highest (most significant) bit set to zero, and negative numbers have that bit (and all bits beyond) set to one, and a negative number is stored in such form by decreasing its absolute value by 1 and swapping the bits of the resulting number.
64-bit floating-point number : A 64-bit binary floating-point number, in the form significand * 2 exponent . The significand is 53 bits long (Precision) and the exponent ranges from -1074 (EMin) to 971 (EMax). The number is stored in the following format (commonly called the IEEE 754 format):
|C|BBB...BBB|AAAAAA...AAAAAA|
-
A. Low 52 bits (Precision minus 1 bits): Lowest bits of the significand.
-
B. Next 11 bits: Exponent area:
-
If all bits are ones, the final stored value is infinity (positive or negative depending on the C bit) if all bits in area A are zeros, or not-a-number (NaN) otherwise.
-
If all bits are zeros, the final stored value is a subnormal number, the exponent is EMin, and the highest bit of the significand is zero.
-
If any other number, the exponent is this value reduced by 1, then raised by EMin, and the highest bit of the significand is one.
-
C. Highest bit: If one, this is a negative number.
The elements described earlier are in the same order as the order of each bit of each element, that is, either most significant first or least significant first.
32-bit binary floating-point number : A 32-bit binary number which is stored similarly to a 64-bit floating-point number , except that:
-
Precision is 24 bits.
-
EMin is -149.
-
EMax is 104.
-
A. The low 23 bits (Precision minus 1 bits) are the lowest bits of the significand.
-
B. The next 8 bits are the exponent area.
-
C. If the highest bit is one, this is a negative number.
.NET Framework decimal : A 128-bit decimal floating-point number, in the form significand * 10 - scale , where the scale ranges from 0 to 28. The number is stored in the following format:
-
Low 96 bits are the significand, as a 96-bit unsigned integer (all 96-bit values are allowed, up to (2 96 -1)).
-
Next 16 bits are unused.
-
Next 8 bits are the scale, stored as an 8-bit unsigned integer.
-
Next 7 bits are unused.
-
If the highest bit is one, it’s a negative number.
The elements described earlier are in the same order as the order of each bit of each element, that is, either most significant first or least significant first.
Member Summary
[Abs()](#Abs)
- Finds the absolute value of this object (if it’s negative, it becomes positive).[Abs(PeterO.Numbers.EContext)](#Abs_PeterO_Numbers_EContext)
- Finds the absolute value of this object (if it’s negative, it becomes positive).[Add(int)](#Add_int)
- Adds this arbitrary-precision decimal floating-point number and a 32-bit signed integer and returns the result.[Add(long)](#Add_long)
- Adds this arbitrary-precision decimal floating-point number and a 64-bit signed integer and returns the result.[Add(PeterO.Numbers.EDecimal)](#Add_PeterO_Numbers_EDecimal)
- Adds this arbitrary-precision decimal floating-point number and another arbitrary-precision decimal floating-point number and returns the result.[Add(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Add_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Adds this arbitrary-precision decimal floating-point number and another arbitrary-precision decimal floating-point number and returns the result.[CompareTo(int)](#CompareTo_int)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareTo(long)](#CompareTo_long)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareTo(PeterO.Numbers.EDecimal)](#CompareTo_PeterO_Numbers_EDecimal)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareToBinary(PeterO.Numbers.EFloat)](#CompareToBinary_PeterO_Numbers_EFloat)
- Compares an arbitrary-precision binary floating-point number with this instance.[CompareToSignal(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#CompareToSignal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Compares the mathematical values of this object and another object, treating quiet NaN as signaling.[CompareToTotal(PeterO.Numbers.EDecimal)](#CompareToTotal_PeterO_Numbers_EDecimal)
- Compares the values of this object and another object, imposing a total ordering on all possible values.[CompareToTotal(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#CompareToTotal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Compares the values of this object and another object, imposing a total ordering on all possible values.[CompareToTotalMagnitude(PeterO.Numbers.EDecimal)](#CompareToTotalMagnitude_PeterO_Numbers_EDecimal)
- Compares the absolute values of this object and another object, imposing a total ordering on all possible values (ignoring their signs).[CompareToTotalMagnitude(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#CompareToTotalMagnitude_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Compares the values of this object and another object, imposing a total ordering on all possible values (ignoring their signs).[CompareToValue(int)](#CompareToValue_int)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareToValue(long)](#CompareToValue_long)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareToValue(PeterO.Numbers.EDecimal)](#CompareToValue_PeterO_Numbers_EDecimal)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareToWithContext(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#CompareToWithContext_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Compares the mathematical values of this object and another object.[Copy()](#Copy)
- Creates a copy of this arbitrary-precision binary number.[CopySign(PeterO.Numbers.EDecimal)](#CopySign_PeterO_Numbers_EDecimal)
- Returns a number with the same value as this one, but copying the sign (positive or negative) of another number.[Create(int, int)](#Create_int_int)
- Returns a number with the value exponent*10^significand.[Create(long, int)](#Create_long_int)
- Creates a number with the value exponent*10^significand.[Create(long, long)](#Create_long_long)
- Creates a number with the value exponent*10^significand.[Create(PeterO.Numbers.EInteger, int)](#Create_PeterO_Numbers_EInteger_int)
- Creates a number with the value exponent*10^significand.[Create(PeterO.Numbers.EInteger, long)](#Create_PeterO_Numbers_EInteger_long)
- Creates a number with the value exponent*10^significand.[Create(PeterO.Numbers.EInteger, PeterO.Numbers.EInteger)](#Create_PeterO_Numbers_EInteger_PeterO_Numbers_EInteger)
- Creates a number with the value exponent*10^significand.[CreateNaN(PeterO.Numbers.EInteger)](#CreateNaN_PeterO_Numbers_EInteger)
- Creates a not-a-number arbitrary-precision decimal number.[CreateNaN(PeterO.Numbers.EInteger, bool, bool, PeterO.Numbers.EContext)](#CreateNaN_PeterO_Numbers_EInteger_bool_bool_PeterO_Numbers_EContext)
- Creates a not-a-number arbitrary-precision decimal number.[Decrement()](#Decrement)
- Returns one subtracted from this arbitrary-precision decimal number.[Divide(int)](#Divide_int)
- Divides this arbitrary-precision decimal floating-point number by a 32-bit signed integer and returns the result; returns NaN instead if the result would have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, and 2/3); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.[Divide(long)](#Divide_long)
- Divides this arbitrary-precision decimal floating-point number by a 64-bit signed integer and returns the result; returns NaN instead if the result would have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, and 2/3); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.[Divide(PeterO.Numbers.EDecimal)](#Divide_PeterO_Numbers_EDecimal)
- Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result; returns NaN instead if the result would have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, and 2/3); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.[Divide(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Divide_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.[DivideAndRemainderNaturalScale(PeterO.Numbers.EDecimal)](#DivideAndRemainderNaturalScale_PeterO_Numbers_EDecimal)
- Obsolete: Renamed to DivRemNaturalScale.[DivideAndRemainderNaturalScale(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#DivideAndRemainderNaturalScale_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Obsolete: Renamed to DivRemNaturalScale.[DivideToExponent(PeterO.Numbers.EDecimal, int)](#DivideToExponent_PeterO_Numbers_EDecimal_int)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 32-bit signed integer) to the result, using the half-even rounding mode.[DivideToExponent(PeterO.Numbers.EDecimal, int, PeterO.Numbers.EContext)](#DivideToExponent_PeterO_Numbers_EDecimal_int_PeterO_Numbers_EContext)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 32-bit signed integer) to the result, using the half-even rounding mode.[DivideToExponent(PeterO.Numbers.EDecimal, int, PeterO.Numbers.ERounding)](#DivideToExponent_PeterO_Numbers_EDecimal_int_PeterO_Numbers_ERounding)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 32-bit signed integer) to the result, using the half-even rounding mode.[DivideToExponent(PeterO.Numbers.EDecimal, long)](#DivideToExponent_PeterO_Numbers_EDecimal_long)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 64-bit signed integer) to the result, using the half-even rounding mode.[DivideToExponent(PeterO.Numbers.EDecimal, long, PeterO.Numbers.EContext)](#DivideToExponent_PeterO_Numbers_EDecimal_long_PeterO_Numbers_EContext)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.[DivideToExponent(PeterO.Numbers.EDecimal, long, PeterO.Numbers.ERounding)](#DivideToExponent_PeterO_Numbers_EDecimal_long_PeterO_Numbers_ERounding)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.[DivideToExponent(PeterO.Numbers.EDecimal, PeterO.Numbers.EInteger)](#DivideToExponent_PeterO_Numbers_EDecimal_PeterO_Numbers_EInteger)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result, using the half-even rounding mode.[DivideToExponent(PeterO.Numbers.EDecimal, PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#DivideToExponent_PeterO_Numbers_EDecimal_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.[DivideToExponent(PeterO.Numbers.EDecimal, PeterO.Numbers.EInteger, PeterO.Numbers.ERounding)](#DivideToExponent_PeterO_Numbers_EDecimal_PeterO_Numbers_EInteger_PeterO_Numbers_ERounding)
- Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.[DivideToIntegerNaturalScale(PeterO.Numbers.EDecimal)](#DivideToIntegerNaturalScale_PeterO_Numbers_EDecimal)
- Divides two arbitrary-precision decimal numbers, and returns the integer part of the result, rounded down, with the preferred exponent set to this value’s exponent minus the divisor’s exponent.[DivideToIntegerNaturalScale(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#DivideToIntegerNaturalScale_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Divides this object by another object, and returns the integer part of the result (which is initially rounded down), with the preferred exponent set to this value’s exponent minus the divisor’s exponent.[DivideToIntegerZeroScale(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#DivideToIntegerZeroScale_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Divides this object by another object, and returns the integer part of the result, with the exponent set to 0.[DivideToSameExponent(PeterO.Numbers.EDecimal, PeterO.Numbers.ERounding)](#DivideToSameExponent_PeterO_Numbers_EDecimal_PeterO_Numbers_ERounding)
- Divides this object by another decimal number and returns a result with the same exponent as this object (the dividend).[DivRemNaturalScale(PeterO.Numbers.EDecimal)](#DivRemNaturalScale_PeterO_Numbers_EDecimal)
- Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns a two-item array containing the result of the division and the remainder, in that order.[DivRemNaturalScale(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#DivRemNaturalScale_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns a two-item array containing the result of the division and the remainder, in that order.[Equals(object)](#Equals_object)
- Determines whether this object’s significand, exponent, and properties are equal to those of another object and that other object is an arbitrary-precision decimal number.[Equals(PeterO.Numbers.EDecimal)](#Equals_PeterO_Numbers_EDecimal)
- Determines whether this object’s significand, exponent, and properties are equal to those of another object.[Exp(PeterO.Numbers.EContext)](#Exp_PeterO_Numbers_EContext)
- Finds e (the base of natural logarithms) raised to the power of this object’s value.[explicit operator byte(PeterO.Numbers.EDecimal)](#explicit_operator_byte_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.[explicit operator decimal(PeterO.Numbers.EDecimal)](#explicit_operator_decimal_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal’s value to a decimal under the Common Language Infrastructure (see T:PeterO.[explicit operator double(PeterO.Numbers.EDecimal)](#explicit_operator_double_PeterO_Numbers_EDecimal)
- Converts this value to its closest equivalent as a 64-bit floating-point number.[explicit operator float(PeterO.Numbers.EDecimal)](#explicit_operator_float_PeterO_Numbers_EDecimal)
- Converts this value to its closest equivalent as a 32-bit floating-point number.[explicit operator int(PeterO.Numbers.EDecimal)](#explicit_operator_int_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator long(PeterO.Numbers.EDecimal)](#explicit_operator_long_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator PeterO.Numbers.EDecimal(bool)](#explicit_operator_PeterO_Numbers_EDecimal_bool)
- Converts a Boolean value (true or false) to an arbitrary precision decimal.[explicit operator PeterO.Numbers.EInteger(PeterO.Numbers.EDecimal)](#explicit_operator_PeterO_Numbers_EInteger_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal floating-point number to an arbitrary-precision integer.[explicit operator sbyte(PeterO.Numbers.EDecimal)](#explicit_operator_sbyte_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator short(PeterO.Numbers.EDecimal)](#explicit_operator_short_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator uint(PeterO.Numbers.EDecimal)](#explicit_operator_uint_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator ulong(PeterO.Numbers.EDecimal)](#explicit_operator_ulong_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.[explicit operator ushort(PeterO.Numbers.EDecimal)](#explicit_operator_ushort_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.[ExpM1(PeterO.Numbers.EContext)](#ExpM1_PeterO_Numbers_EContext)
- Finds e (the base of natural logarithms) raised to the power of this object’s value, and subtracts the result by 1 and returns the final result, in a way that avoids loss of precision if the true result is very close to 0.[Exponent](#Exponent)
- Gets this object’s exponent.[FromBoolean(bool)](#FromBoolean_bool)
- Converts a Boolean value (true or false) to an arbitrary-precision decimal number.[FromByte(byte)](#FromByte_byte)
- Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.[FromDecimal(decimal)](#FromDecimal_decimal)
- Converts a decimal under the Common Language Infrastructure (see T:PeterO.[FromDouble(double)](#FromDouble_double)
- Creates an arbitrary-precision decimal number from a 64-bit binary floating-point number.[FromDoubleBits(long)](#FromDoubleBits_long)
- Creates an arbitrary-precision decimal number from a 64-bit binary floating-point number, encoded in the IEEE 754 binary64 format.[FromEFloat(PeterO.Numbers.EFloat)](#FromEFloat_PeterO_Numbers_EFloat)
- Creates an arbitrary-precision decimal number from an arbitrary-precision binary floating-point number.[FromEInteger(PeterO.Numbers.EInteger)](#FromEInteger_PeterO_Numbers_EInteger)
- Converts an arbitrary-precision integer to an arbitrary precision decimal.[FromExtendedFloat(PeterO.Numbers.EFloat)](#FromExtendedFloat_PeterO_Numbers_EFloat)
- Obsolete: Renamed to FromEFloat.[FromHalfBits(short)](#FromHalfBits_short)
- Creates a decimal floating-point number from a binary floating-point number encoded in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number).[FromInt16(short)](#FromInt16_short)
- Converts a 16-bit signed integer to an arbitrary-precision decimal number.[FromInt32(int)](#FromInt32_int)
- Creates an arbitrary-precision decimal number from a 32-bit signed integer.[FromInt64(long)](#FromInt64_long)
- Creates an arbitrary-precision decimal number from a 64-bit signed integer.[FromInt64AsUnsigned(long)](#FromInt64AsUnsigned_long)
- Converts an unsigned integer expressed as a 64-bit signed integer to an arbitrary-precision decimal number.[FromSByte(sbyte)](#FromSByte_sbyte)
- Converts an 8-bit signed integer to an arbitrary-precision decimal number.[FromSingle(float)](#FromSingle_float)
- Creates an arbitrary-precision decimal number from a 32-bit binary floating-point number.[FromSingleBits(int)](#FromSingleBits_int)
- Creates an arbitrary-precision decimal number from a 32-bit binary floating-point number encoded in the IEEE 754 binary32 format.[FromString(byte[])](#FromString_byte)
- Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number.[FromString(byte[], int, int)](#FromString_byte_int_int)
- Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number.[FromString(byte[], int, int, PeterO.Numbers.EContext)](#FromString_byte_int_int_PeterO_Numbers_EContext)
- Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number.[FromString(byte[], PeterO.Numbers.EContext)](#FromString_byte_PeterO_Numbers_EContext)
- Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number.[FromString(char[])](#FromString_char)
- Creates an arbitrary-precision decimal number from a sequence of char s that represents a number.[FromString(char[], int, int)](#FromString_char_int_int)
- Creates an arbitrary-precision decimal number from a sequence of char s that represents a number.[FromString(char[], int, int, PeterO.Numbers.EContext)](#FromString_char_int_int_PeterO_Numbers_EContext)
- Creates an arbitrary-precision decimal number from a sequence of char s that represents a number.[FromString(char[], PeterO.Numbers.EContext)](#FromString_char_PeterO_Numbers_EContext)
- Creates an arbitrary-precision decimal number from a sequence of char s that represents a number.[FromString(string)](#FromString_string)
- Creates an arbitrary-precision decimal number from a text string that represents a number.[FromString(string, int, int)](#FromString_string_int_int)
- Creates an arbitrary-precision decimal number from a text string that represents a number.[FromString(string, int, int, PeterO.Numbers.EContext)](#FromString_string_int_int_PeterO_Numbers_EContext)
- Creates an arbitrary-precision decimal number from a text string that represents a number.[FromString(string, PeterO.Numbers.EContext)](#FromString_string_PeterO_Numbers_EContext)
- Creates an arbitrary-precision decimal number from a text string that represents a number.[FromUInt16(ushort)](#FromUInt16_ushort)
- Converts a 16-bit unsigned integer to an arbitrary-precision decimal number.[FromUInt32(uint)](#FromUInt32_uint)
- Converts a 32-bit signed integer to an arbitrary-precision decimal number.[FromUInt64(ulong)](#FromUInt64_ulong)
- Converts a 64-bit unsigned integer to an arbitrary-precision decimal number.[GetHashCode()](#GetHashCode)
- Calculates this object’s hash code.[implicit operator PeterO.Numbers.EDecimal(byte)](#implicit_operator_PeterO_Numbers_EDecimal_byte)
- Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(decimal)](#implicit_operator_PeterO_Numbers_EDecimal_decimal)
- Converts an arbitrary-precision decimal number to a decimal under the Common Language Infrastructure (see T:PeterO.[implicit operator PeterO.Numbers.EDecimal(int)](#implicit_operator_PeterO_Numbers_EDecimal_int)
- Converts a 32-bit signed integer to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(long)](#implicit_operator_PeterO_Numbers_EDecimal_long)
- Converts a 64-bit signed integer to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(PeterO.Numbers.EInteger)](#implicit_operator_PeterO_Numbers_EDecimal_PeterO_Numbers_EInteger)
- Converts an arbitrary-precision integer to an arbitrary precision decimal.[implicit operator PeterO.Numbers.EDecimal(sbyte)](#implicit_operator_PeterO_Numbers_EDecimal_sbyte)
- Converts an 8-bit signed integer to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(short)](#implicit_operator_PeterO_Numbers_EDecimal_short)
- Converts a 16-bit signed integer to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(uint)](#implicit_operator_PeterO_Numbers_EDecimal_uint)
- Converts a 32-bit signed integer to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(ulong)](#implicit_operator_PeterO_Numbers_EDecimal_ulong)
- Converts a 64-bit unsigned integer to an arbitrary-precision decimal number.[implicit operator PeterO.Numbers.EDecimal(ushort)](#implicit_operator_PeterO_Numbers_EDecimal_ushort)
- Converts a 16-bit unsigned integer to an arbitrary-precision decimal number.[Increment()](#Increment)
- Returns one added to this arbitrary-precision decimal number.[IsFinite](#IsFinite)
- Gets a value indicating whether this object is finite (not infinity or NaN).[IsInfinity()](#IsInfinity)
- Gets a value indicating whether this object is positive or negative infinity.[IsInteger()](#IsInteger)
- Returns whether this object’s value is an integer.[IsNaN()](#IsNaN)
- Gets a value indicating whether this object is not a number (NaN).[IsNegative](#IsNegative)
- Gets a value indicating whether this object is negative, including negative zero.[IsNegativeInfinity()](#IsNegativeInfinity)
- Returns whether this object is negative infinity.[IsPositiveInfinity()](#IsPositiveInfinity)
- Returns whether this object is positive infinity.[IsQuietNaN()](#IsQuietNaN)
- Gets a value indicating whether this object is a quiet not-a-number value.[IsSignalingNaN()](#IsSignalingNaN)
- Gets a value indicating whether this object is a signaling not-a-number value.[IsZero](#IsZero)
- Gets a value indicating whether this object’s value equals 0.[Log(PeterO.Numbers.EContext)](#Log_PeterO_Numbers_EContext)
- Finds the natural logarithm of this object, that is, the power (exponent) that e (the base of natural logarithms) must be raised to in order to equal this object’s value.[Log10(PeterO.Numbers.EContext)](#Log10_PeterO_Numbers_EContext)
- Finds the base-10 logarithm of this object, that is, the power (exponent) that the number 10 must be raised to in order to equal this object’s value.[Log1P(PeterO.Numbers.EContext)](#Log1P_PeterO_Numbers_EContext)
- Adds 1 to this object’s value and finds the natural logarithm of the result, in a way that avoids loss of precision when this object’s value is between 0 and 1.[LogN(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#LogN_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Finds the base-N logarithm of this object, that is, the power (exponent) that the number N must be raised to in order to equal this object’s value.[Mantissa](#Mantissa)
- Gets this object’s unscaled value, or significand, and makes it negative if this object is negative.[Max(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#Max_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal)
- Gets the greater value between two decimal numbers.[Max(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Max_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Gets the greater value between two decimal numbers.[MaxMagnitude(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#MaxMagnitude_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal)
- Gets the greater value between two values, ignoring their signs.[MaxMagnitude(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#MaxMagnitude_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Gets the greater value between two values, ignoring their signs.[Min(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#Min_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal)
- Gets the lesser value between two decimal numbers.[Min(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Min_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Gets the lesser value between two decimal numbers.[MinMagnitude(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#MinMagnitude_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal)
- Gets the lesser value between two values, ignoring their signs.[MinMagnitude(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#MinMagnitude_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Gets the lesser value between two values, ignoring their signs.[MovePointLeft(int)](#MovePointLeft_int)
- Returns a number similar to this number but with the decimal point moved to the left.[MovePointLeft(int, PeterO.Numbers.EContext)](#MovePointLeft_int_PeterO_Numbers_EContext)
- Returns a number similar to this number but with the decimal point moved to the left.[MovePointLeft(PeterO.Numbers.EInteger)](#MovePointLeft_PeterO_Numbers_EInteger)
- Returns a number similar to this number but with the decimal point moved to the left.[MovePointLeft(PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#MovePointLeft_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Returns a number similar to this number but with the decimal point moved to the left.[MovePointRight(int)](#MovePointRight_int)
- Returns a number similar to this number but with the decimal point moved to the right.[MovePointRight(int, PeterO.Numbers.EContext)](#MovePointRight_int_PeterO_Numbers_EContext)
- Returns a number similar to this number but with the decimal point moved to the right.[MovePointRight(PeterO.Numbers.EInteger)](#MovePointRight_PeterO_Numbers_EInteger)
- Returns a number similar to this number but with the decimal point moved to the right.[MovePointRight(PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#MovePointRight_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Returns a number similar to this number but with the decimal point moved to the right.[Multiply(int)](#Multiply_int)
- Multiplies this arbitrary-precision decimal floating-point number by a 32-bit signed integer and returns the result.[Multiply(long)](#Multiply_long)
- Multiplies this arbitrary-precision decimal floating-point number by a 64-bit signed integer and returns the result.[Multiply(PeterO.Numbers.EDecimal)](#Multiply_PeterO_Numbers_EDecimal)
- Multiplies this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.[Multiply(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Multiply_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Multiplies this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.[MultiplyAndAdd(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#MultiplyAndAdd_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal)
- Multiplies by one decimal number, and then adds another decimal number.[MultiplyAndAdd(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#MultiplyAndAdd_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Multiplies by one value, and then adds another value.[MultiplyAndSubtract(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#MultiplyAndSubtract_PeterO_Numbers_EDecimal_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Multiplies by one value, and then subtracts another value.[public static readonly PeterO.Numbers.EDecimal NaN;](#NaN)
- A not-a-number value.[Negate()](#Negate)
- Gets an object with the same value as this one, but with the sign reversed.[Negate(PeterO.Numbers.EContext)](#Negate_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but with the sign reversed.[public static readonly PeterO.Numbers.EDecimal NegativeInfinity;](#NegativeInfinity)
- Negative infinity, less than any other number.[public static readonly PeterO.Numbers.EDecimal NegativeZero;](#NegativeZero)
- Represents the number negative zero.[NextMinus(PeterO.Numbers.EContext)](#NextMinus_PeterO_Numbers_EContext)
- Finds the largest value that’s smaller than the specified value.[NextPlus(PeterO.Numbers.EContext)](#NextPlus_PeterO_Numbers_EContext)
- Finds the smallest value that’s greater than the specified value.[NextToward(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#NextToward_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Finds the next value that is closer to the other object’s value than this object’s value.[public static readonly PeterO.Numbers.EDecimal One;](#One)
- Represents the number 1.[PeterO.Numbers.EDecimal operator +(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#op_Addition)
- Adds an arbitrary-precision decimal floating-point number and another arbitrary-precision decimal floating-point number and returns the result.[PeterO.Numbers.EDecimal operator --(PeterO.Numbers.EDecimal)](#op_Decrement)
- Subtracts one from an arbitrary-precision decimal number.[PeterO.Numbers.EDecimal operator /(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#op_Division)
- Divides this object by another decimal number and returns the result.[PeterO.Numbers.EDecimal operator ++(PeterO.Numbers.EDecimal)](#op_Increment)
- Adds one to an arbitrary-precision decimal number.[PeterO.Numbers.EDecimal operator %(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#op_Modulus)
- Returns the remainder that would result when an arbitrary-precision decimal floating-point number is divided by another arbitrary-precision decimal floating-point number.[PeterO.Numbers.EDecimal operator *(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#op_Multiply)
- Multiplies an arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.[PeterO.Numbers.EDecimal operator -(PeterO.Numbers.EDecimal, PeterO.Numbers.EDecimal)](#op_Subtraction)
- Subtracts one arbitrary-precision decimal number from another and returns the result.[PeterO.Numbers.EDecimal operator -(PeterO.Numbers.EDecimal)](#op_UnaryNegation)
- Gets an arbitrary-precision decimal number with the same value as the specified one, but with the sign reversed.[PI(PeterO.Numbers.EContext)](#PI_PeterO_Numbers_EContext)
- Finds the constant π, the circumference of a circle divided by its diameter.[Plus(PeterO.Numbers.EContext)](#Plus_PeterO_Numbers_EContext)
- Rounds this object’s value to the specified precision, using the specified rounding mode and range of exponent, and also converts negative zero to positive zero.[public static readonly PeterO.Numbers.EDecimal PositiveInfinity;](#PositiveInfinity)
- Positive infinity, greater than any other number.[Pow(int)](#Pow_int)
- Raises this object’s value to the specified exponent.[Pow(int, PeterO.Numbers.EContext)](#Pow_int_PeterO_Numbers_EContext)
- Raises this object’s value to the specified exponent.[Pow(PeterO.Numbers.EDecimal)](#Pow_PeterO_Numbers_EDecimal)
- Raises this object’s value to the specified exponent, using unlimited precision.[Pow(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Pow_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Raises this object’s value to the specified exponent.[Precision()](#Precision)
- Finds the number of digits in this number’s significand.[PreRound(PeterO.Numbers.EContext)](#PreRound_PeterO_Numbers_EContext)
- Returns a number in which the value of this object is rounded to fit the maximum precision allowed if it has more significant digits than the maximum precision.[Quantize(int, PeterO.Numbers.EContext)](#Quantize_int_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value but a new exponent.[Quantize(int, PeterO.Numbers.ERounding)](#Quantize_int_PeterO_Numbers_ERounding)
- Returns an arbitrary-precision decimal number with the same value as this one but a new exponent.[Quantize(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Quantize_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but with the same exponent as another decimal number.[Quantize(PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#Quantize_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value but a new exponent.[Reduce(PeterO.Numbers.EContext)](#Reduce_PeterO_Numbers_EContext)
- Returns an object with the same numerical value as this one but with trailing zeros removed from its significand.[Remainder(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Remainder_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Returns the remainder that would result when this arbitrary-precision decimal floating-point number is divided by another arbitrary-precision decimal floating-point number.[RemainderNaturalScale(PeterO.Numbers.EDecimal)](#RemainderNaturalScale_PeterO_Numbers_EDecimal)
- Calculates the remainder of a number by the formula “this” - ((“this” / “divisor”) * “divisor”).[RemainderNaturalScale(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#RemainderNaturalScale_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Calculates the remainder of a number by the formula “this” - ((“this” / “divisor”) * “divisor”).[RemainderNear(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#RemainderNear_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Finds the distance to the closest multiple of the specified divisor, based on the result of dividing this object’s value by another object’s value.[RemainderNoRoundAfterDivide(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#RemainderNoRoundAfterDivide_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Finds the remainder that results when dividing two arbitrary-precision decimal numbers, except the intermediate division is not adjusted to fit the precision of the specified arithmetic context.[RoundToExponent(int)](#RoundToExponent_int)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary, using the HalfEven rounding mode.[RoundToExponent(int, PeterO.Numbers.EContext)](#RoundToExponent_int_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary.[RoundToExponent(int, PeterO.Numbers.ERounding)](#RoundToExponent_int_PeterO_Numbers_ERounding)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary.[RoundToExponent(PeterO.Numbers.EInteger)](#RoundToExponent_PeterO_Numbers_EInteger)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary, using the HalfEven rounding mode.[RoundToExponent(PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#RoundToExponent_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary.[RoundToExponent(PeterO.Numbers.EInteger, PeterO.Numbers.ERounding)](#RoundToExponent_PeterO_Numbers_EInteger_PeterO_Numbers_ERounding)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary, using the specified rounding mode.[RoundToExponentExact(int, PeterO.Numbers.EContext)](#RoundToExponentExact_int_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to the specified exponent represented as a 32-bit signed integer, and signals an inexact flag if the result would be inexact.[RoundToExponentExact(int, PeterO.Numbers.ERounding)](#RoundToExponentExact_int_PeterO_Numbers_ERounding)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to the specified exponent represented as a 32-bit signed integer, and signals an inexact flag if the result would be inexact.[RoundToExponentExact(PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#RoundToExponentExact_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to the specified exponent represented as an arbitrary-precision integer, and signals an inexact flag if the result would be inexact.[RoundToIntegerExact(PeterO.Numbers.EContext)](#RoundToIntegerExact_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to an integer, and signals an inexact flag if the result would be inexact.[RoundToIntegerNoRoundedFlag(PeterO.Numbers.EContext)](#RoundToIntegerNoRoundedFlag_PeterO_Numbers_EContext)
- Returns an arbitrary-precision decimal number with the same value as this object but rounded to an integer, without adding the FlagInexact or FlagRounded flags.[RoundToIntegralExact(PeterO.Numbers.EContext)](#RoundToIntegralExact_PeterO_Numbers_EContext)
- Obsolete: Renamed to RoundToIntegerExact.[RoundToIntegralNoRoundedFlag(PeterO.Numbers.EContext)](#RoundToIntegralNoRoundedFlag_PeterO_Numbers_EContext)
- Obsolete: Renamed to RoundToIntegerNoRoundedFlag.[RoundToPrecision(PeterO.Numbers.EContext)](#RoundToPrecision_PeterO_Numbers_EContext)
- Rounds this object’s value to the specified precision, using the specified rounding mode and range of exponent.[ScaleByPowerOfTen(int)](#ScaleByPowerOfTen_int)
- Returns a number similar to this number but with the scale adjusted.[ScaleByPowerOfTen(int, PeterO.Numbers.EContext)](#ScaleByPowerOfTen_int_PeterO_Numbers_EContext)
- Returns a number similar to this number but with the scale adjusted.[ScaleByPowerOfTen(PeterO.Numbers.EInteger)](#ScaleByPowerOfTen_PeterO_Numbers_EInteger)
- Returns a number similar to this number but with the scale adjusted.[ScaleByPowerOfTen(PeterO.Numbers.EInteger, PeterO.Numbers.EContext)](#ScaleByPowerOfTen_PeterO_Numbers_EInteger_PeterO_Numbers_EContext)
- Returns a number similar to this number but with its scale adjusted.[Sign](#Sign)
- Gets this value’s sign: -1 if negative; 1 if positive; 0 if zero.[public static readonly PeterO.Numbers.EDecimal SignalingNaN;](#SignalingNaN)
- A not-a-number value that signals an invalid operation flag when it’s passed as an argument to any arithmetic operation in arbitrary-precision decimal.[Sqrt(PeterO.Numbers.EContext)](#Sqrt_PeterO_Numbers_EContext)
- Finds the square root of this object’s value.[SquareRoot(PeterO.Numbers.EContext)](#SquareRoot_PeterO_Numbers_EContext)
- Obsolete: Renamed to Sqrt.[Subtract(int)](#Subtract_int)
- Subtracts a 32-bit signed integer from this arbitrary-precision decimal floating-point number and returns the result.[Subtract(long)](#Subtract_long)
- Subtracts a 64-bit signed integer from this arbitrary-precision decimal floating-point number and returns the result.[Subtract(PeterO.Numbers.EDecimal)](#Subtract_PeterO_Numbers_EDecimal)
- Subtracts an arbitrary-precision decimal floating-point number from this arbitrary-precision decimal floating-point number and returns the result.[Subtract(PeterO.Numbers.EDecimal, PeterO.Numbers.EContext)](#Subtract_PeterO_Numbers_EDecimal_PeterO_Numbers_EContext)
- Subtracts an arbitrary-precision decimal floating-point number from this arbitrary-precision decimal floating-point number and returns the result.[public static readonly PeterO.Numbers.EDecimal Ten;](#Ten)
- Represents the number 10.[ToByteChecked()](#ToByteChecked)
- Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.[ToByteIfExact()](#ToByteIfExact)
- Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.[ToByteUnchecked()](#ToByteUnchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a byte (from 0 to 255).[ToDecimal()](#ToDecimal)
- Converts this value to a decimal under the Common Language Infrastructure (see T:PeterO.[ToDouble()](#ToDouble)
- Converts this value to its closest equivalent as a 64-bit floating-point number, using the half-even rounding mode.[ToDoubleBits()](#ToDoubleBits)
- Converts this value to its closest equivalent as a 64-bit floating-point number encoded in the IEEE 754 binary64 format, using the half-even rounding mode.[ToEFloat()](#ToEFloat)
- Creates a binary floating-point number from this object’s value.[ToEFloat(PeterO.Numbers.EContext)](#ToEFloat_PeterO_Numbers_EContext)
- Creates a binary floating-point number from this object’s value.[ToEInteger()](#ToEInteger)
- Converts this value to an arbitrary-precision integer, discarding the fractional part in this value.[ToEIntegerExact()](#ToEIntegerExact)
- Obsolete: Renamed to ToEIntegerIfExact.[ToEIntegerIfExact()](#ToEIntegerIfExact)
- Converts this value to an arbitrary-precision integer, checking whether the fractional part of the value would be lost.[ToEngineeringString()](#ToEngineeringString)
- Same as ToString(), except that when an exponent is used it will be a multiple of 3.[ToExtendedFloat()](#ToExtendedFloat)
- Obsolete: Renamed to ToEFloat.[ToHalfBits()](#ToHalfBits)
- Converts this value to its closest equivalent as a binary floating-point number, expressed as an integer in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number).[ToInt16Checked()](#ToInt16Checked)
- Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.[ToInt16IfExact()](#ToInt16IfExact)
- Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer without rounding to a different numerical value.[ToInt16Unchecked()](#ToInt16Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit signed integer.[ToInt32Checked()](#ToInt32Checked)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[ToInt32IfExact()](#ToInt32IfExact)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.[ToInt32Unchecked()](#ToInt32Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.[ToInt64Checked()](#ToInt64Checked)
- Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.[ToInt64IfExact()](#ToInt64IfExact)
- Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer without rounding to a different numerical value.[ToInt64Unchecked()](#ToInt64Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit signed integer.[ToPlainString()](#ToPlainString)
- Converts this value to a string as though with the ToString method, but without using exponential notation.[ToSByteChecked()](#ToSByteChecked)
- Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.[ToSByteIfExact()](#ToSByteIfExact)
- Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer without rounding to a different numerical value.[ToSByteUnchecked()](#ToSByteUnchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as an 8-bit signed integer.[ToSingle()](#ToSingle)
- Converts this value to its closest equivalent as a 32-bit floating-point number, using the half-even rounding mode.[ToSingleBits()](#ToSingleBits)
- Converts this value to its closest equivalent as a 32-bit floating-point number encoded in the IEEE 754 binary32 format, using the half-even rounding mode.[ToSizedEInteger(int)](#ToSizedEInteger_int)
- Converts this value to an arbitrary-precision integer by discarding its fractional part and checking whether the resulting integer overflows the specified signed bit count.[ToSizedEIntegerIfExact(int)](#ToSizedEIntegerIfExact_int)
- Converts this value to an arbitrary-precision integer, only if this number’s value is an exact integer and that integer does not overflow the specified signed bit count.[ToString()](#ToString)
- Converts this value to a text string.[ToUInt16Checked()](#ToUInt16Checked)
- Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.[ToUInt16IfExact()](#ToUInt16IfExact)
- Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer without rounding to a different numerical value.[ToUInt16Unchecked()](#ToUInt16Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit unsigned integer.[ToUInt32Checked()](#ToUInt32Checked)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[ToUInt32IfExact()](#ToUInt32IfExact)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.[ToUInt32Unchecked()](#ToUInt32Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.[ToUInt64Checked()](#ToUInt64Checked)
- Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.[ToUInt64IfExact()](#ToUInt64IfExact)
- Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer without rounding to a different numerical value.[ToUInt64Unchecked()](#ToUInt64Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit unsigned integer.[Ulp()](#Ulp)
- Returns the unit in the last place.[UnsignedMantissa](#UnsignedMantissa)
- Gets the absolute value of this object’s unscaled value, or significand.[public static readonly PeterO.Numbers.EDecimal Zero;](#Zero)
- Represents the number 0.
public static readonly PeterO.Numbers.EDecimal NaN;
A not-a-number value.
public static readonly PeterO.Numbers.EDecimal NegativeInfinity;
Negative infinity, less than any other number.
public static readonly PeterO.Numbers.EDecimal NegativeZero;
Represents the number negative zero.
public static readonly PeterO.Numbers.EDecimal One;
Represents the number 1.
public static readonly PeterO.Numbers.EDecimal PositiveInfinity;
Positive infinity, greater than any other number.
public static readonly PeterO.Numbers.EDecimal SignalingNaN;
A not-a-number value that signals an invalid operation flag when it’s passed as an argument to any arithmetic operation in arbitrary-precision decimal.
public static readonly PeterO.Numbers.EDecimal Ten;
Represents the number 10.
public static readonly PeterO.Numbers.EDecimal Zero;
Represents the number 0.
public PeterO.Numbers.EInteger Exponent { get; }
Gets this object’s exponent. This object’s value will be an integer if the exponent is positive or zero.
Returns:
This object’s exponent. This object’s value will be an integer if the exponent is positive or zero.
public bool IsFinite { get; }
Gets a value indicating whether this object is finite (not infinity or NaN).
Returns:
true
if this object is finite (not infinity or NaN); otherwise, false
.
public bool IsNegative { get; }
Gets a value indicating whether this object is negative, including negative zero.
Returns:
true
if this object is negative, including negative zero; otherwise, false
.
public bool IsZero { get; }
Gets a value indicating whether this object’s value equals 0.
Returns:
true
if this object’s value equals 0; otherwise, false
. true
if this object’s value equals 0; otherwise, false
.
public PeterO.Numbers.EInteger Mantissa { get; }
Gets this object’s unscaled value, or significand, and makes it negative if this object is negative. If this value is not-a-number (NaN), that value’s absolute value is the NaN’s “payload” (diagnostic information).
Returns:
This object’s unscaled value. Will be negative if this object’s value is negative (including a negative NaN).
public int Sign { get; }
Gets this value’s sign: -1 if negative; 1 if positive; 0 if zero.
Returns:
This value’s sign: -1 if negative; 1 if positive; 0 if zero.
public PeterO.Numbers.EInteger UnsignedMantissa { get; }
Gets the absolute value of this object’s unscaled value, or significand. If this value is not-a-number (NaN), that value is the NaN’s “payload” (diagnostic information).
Returns:
The absolute value of this object’s unscaled value.
public PeterO.Numbers.EDecimal Abs( PeterO.Numbers.EContext context);
Finds the absolute value of this object (if it’s negative, it becomes positive).
Parameters:
- context: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The absolute value of this object. Signals FlagInvalid and returns quiet NaN if this value is signaling NaN.
public PeterO.Numbers.EDecimal Abs();
Finds the absolute value of this object (if it’s negative, it becomes positive).
Return Value:
An arbitrary-precision decimal number. Returns signaling NaN if this value is signaling NaN. (In this sense, this method is similar to the “copy-abs” operation in the General Decimal Arithmetic Specification, except this method does not necessarily return a copy of this object.).
public PeterO.Numbers.EDecimal Add( int intValue);
Adds this arbitrary-precision decimal floating-point number and a 32-bit signed integer and returns the result. The exponent for the result is the lower of this arbitrary-precision decimal floating-point number’s exponent and the other 32-bit signed integer’s exponent.
Parameters:
- intValue: A 32-bit signed integer to add to this object.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision decimal floating-point number plus a 32-bit signed integer. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public PeterO.Numbers.EDecimal Add( long longValue);
Adds this arbitrary-precision decimal floating-point number and a 64-bit signed integer and returns the result. The exponent for the result is the lower of this arbitrary-precision decimal floating-point number’s exponent and the other 64-bit signed integer’s exponent.
Parameters:
- longValue: The parameter longValue is a 64-bit signed integer.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision decimal floating-point number plus a 64-bit signed integer. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public PeterO.Numbers.EDecimal Add( PeterO.Numbers.EDecimal otherValue, PeterO.Numbers.EContext ctx);
Adds this arbitrary-precision decimal floating-point number and another arbitrary-precision decimal floating-point number and returns the result.
Parameters:
-
otherValue: The number to add to.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision decimal floating-point number plus another arbitrary-precision decimal floating-point number. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public PeterO.Numbers.EDecimal Add( PeterO.Numbers.EDecimal otherValue);
Adds this arbitrary-precision decimal floating-point number and another arbitrary-precision decimal floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision decimal floating-point number’s exponent and the other arbitrary-precision decimal floating-point number’s exponent.
Parameters:
- otherValue: An arbitrary-precision decimal number.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision decimal floating-point number plus another arbitrary-precision decimal floating-point number. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public int CompareTo( int intOther);
Compares the mathematical values of this object and another object, accepting NaN values. This method currently uses the rules given in the CompareToValue method, so that it it is not consistent with the Equals method, but it may change in a future version to use the rules for the CompareToTotal method instead.
Parameters:
- intOther: The parameter intOther is a 32-bit signed integer.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value, or 0 if both values are equal.
public int CompareTo( long intOther);
Compares the mathematical values of this object and another object, accepting NaN values. This method currently uses the rules given in the CompareToValue method, so that it it is not consistent with the Equals method, but it may change in a future version to use the rules for the CompareToTotal method instead.
Parameters:
- intOther: The parameter intOther is a 64-bit signed integer.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value, or 0 if both values are equal.
public sealed int CompareTo( PeterO.Numbers.EDecimal other);
Compares the mathematical values of this object and another object, accepting NaN values. This method currently uses the rules given in the CompareToValue method, so that it it is not consistent with the Equals method, but it may change in a future version to use the rules for the CompareToTotal method instead.
Parameters:
- other: An arbitrary-precision decimal number.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value or if other
is null, or 0 if both values are equal. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToBinary( PeterO.Numbers.EFloat other);
Compares an arbitrary-precision binary floating-point number with this instance.
Parameters:
- other: The other object to compare. Can be null.
Return Value:
Zero if the values are equal; a negative number if this instance is less; or a positive number if this instance is greater. Returns 0 if both values are NaN (even signaling NaN) and 1 if this value is NaN (even signaling NaN) and the other isn’t, or if the other value is null. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public PeterO.Numbers.EDecimal CompareToSignal( PeterO.Numbers.EDecimal other, PeterO.Numbers.EContext ctx);
Compares the mathematical values of this object and another object, treating quiet NaN as signaling. In this method, negative zero and positive zero are considered equal.
If this object or the other object is a quiet NaN or signaling NaN, this method will return a quiet NaN and will signal a FlagInvalid flag.
Parameters:
-
other: An arbitrary-precision decimal number.
-
ctx: An arithmetic context. The precision, rounding, and exponent range are ignored. If
HasFlags
of the context is true, will store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null.
Return Value:
Quiet NaN if this object or the other object is NaN, or 0 if both objects have the same value, or -1 if this object is less than the other value, or a 1 if this object is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToTotal( PeterO.Numbers.EDecimal other, PeterO.Numbers.EContext ctx);
Compares the values of this object and another object, imposing a total ordering on all possible values. In this method:
-
For objects with the same value, the one with the higher exponent has a greater “absolute value”.
-
Negative zero is less than positive zero.
-
Quiet NaN has a higher “absolute value” than signaling NaN. If both objects are quiet NaN or both are signaling NaN, the one with the higher diagnostic information has a greater “absolute value”.
-
NaN has a higher “absolute value” than infinity.
-
Infinity has a higher “absolute value” than any finite number.
-
Negative numbers are less than positive numbers.
Parameters:
-
other: An arbitrary-precision decimal number to compare with this one.
-
ctx: An arithmetic context. Flags will be set in this context only if
HasFlags
andIsSimplified
of the context are true and only if an operand needed to be rounded before carrying out the operation. Can be null.
Return Value:
The number 0 if both objects have the same value, or -1 if this object is less than the other value, or 1 if this object is greater. Does not signal flags if either value is signaling NaN. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToTotal( PeterO.Numbers.EDecimal other);
Compares the values of this object and another object, imposing a total ordering on all possible values. In this method:
-
For objects with the same value, the one with the higher exponent has a greater “absolute value”.
-
Negative zero is less than positive zero.
-
Quiet NaN has a higher “absolute value” than signaling NaN. If both objects are quiet NaN or both are signaling NaN, the one with the higher diagnostic information has a greater “absolute value”.
-
NaN has a higher “absolute value” than infinity.
-
Infinity has a higher “absolute value” than any finite number.
-
Negative numbers are less than positive numbers.
Parameters:
- other: An arbitrary-precision decimal number to compare with this one.
Return Value:
The number 0 if both objects have the same value, or -1 if this object is less than the other value, or 1 if this object is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToTotalMagnitude( PeterO.Numbers.EDecimal other, PeterO.Numbers.EContext ctx);
Compares the values of this object and another object, imposing a total ordering on all possible values (ignoring their signs). In this method:
-
For objects with the same value, the one with the higher exponent has a greater “absolute value”.
-
Negative zero is less than positive zero.
-
Quiet NaN has a higher “absolute value” than signaling NaN. If both objects are quiet NaN or both are signaling NaN, the one with the higher diagnostic information has a greater “absolute value”.
-
NaN has a higher “absolute value” than infinity.
-
Infinity has a higher “absolute value” than any finite number.
-
Negative numbers are less than positive numbers.
Parameters:
-
other: An arbitrary-precision decimal number to compare with this one.
-
ctx: An arithmetic context. Flags will be set in this context only if
HasFlags
andIsSimplified
of the context are true and only if an operand needed to be rounded before carrying out the operation. Can be null.
Return Value:
The number 0 if both objects have the same value (ignoring their signs), or -1 if this object is less than the other value (ignoring their signs), or 1 if this object is greater (ignoring their signs). Does not signal flags if either value is signaling NaN. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToTotalMagnitude( PeterO.Numbers.EDecimal other);
Compares the absolute values of this object and another object, imposing a total ordering on all possible values (ignoring their signs). In this method:
-
For objects with the same value, the one with the higher exponent has a greater “absolute value”.
-
Negative zero and positive zero are considered equal.
-
Quiet NaN has a higher “absolute value” than signaling NaN. If both objects are quiet NaN or both are signaling NaN, the one with the higher diagnostic information has a greater “absolute value”.
-
NaN has a higher “absolute value” than infinity.
-
Infinity has a higher “absolute value” than any finite number.
Parameters:
- other: An arbitrary-precision decimal number to compare with this one.
Return Value:
The number 0 if both objects have the same value (ignoring their signs), or -1 if this object is less than the other value (ignoring their signs), or 1 if this object is greater (ignoring their signs). This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToValue( int intOther);
Compares the mathematical values of this object and another object, accepting NaN values. This method is not consistent with the Equals method because two different numbers with the same mathematical value, but different exponents, will compare as equal.
In this method, negative zero and positive zero are considered equal.
If this object is a quiet NaN or signaling NaN, this method will not trigger an error. Instead, NaN will compare greater than any other number, including infinity.
Parameters:
- intOther: The parameter intOther is a 32-bit signed integer.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value, or 0 if both values are equal.
public int CompareToValue( long intOther);
Compares the mathematical values of this object and another object, accepting NaN values. This method is not consistent with the Equals method because two different numbers with the same mathematical value, but different exponents, will compare as equal.
In this method, negative zero and positive zero are considered equal.
If this object is a quiet NaN or signaling NaN, this method will not trigger an error. Instead, NaN will compare greater than any other number, including infinity.
Parameters:
- intOther: The parameter intOther is a 64-bit signed integer.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value, or 0 if both values are equal.
public int CompareToValue( PeterO.Numbers.EDecimal other);
Compares the mathematical values of this object and another object, accepting NaN values. This method is not consistent with the Equals method because two different numbers with the same mathematical value, but different exponents, will compare as equal.
In this method, negative zero and positive zero are considered equal.
If this object or the other object is a quiet NaN or signaling NaN, this method will not trigger an error. Instead, NaN will compare greater than any other number, including infinity. Two different NaN values will be considered equal.
Parameters:
- other: An arbitrary-precision decimal number.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value or if other
is null, or 0 if both values are equal. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public PeterO.Numbers.EDecimal CompareToWithContext( PeterO.Numbers.EDecimal other, PeterO.Numbers.EContext ctx);
Compares the mathematical values of this object and another object. In this method, negative zero and positive zero are considered equal.
If this object or the other object is a quiet NaN or signaling NaN, this method returns a quiet NaN, and will signal a FlagInvalid flag if either is a signaling NaN.
Parameters:
-
other: An arbitrary-precision decimal number.
-
ctx: An arithmetic context. The precision, rounding, and exponent range are ignored. If
HasFlags
of the context is true, will store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null.
Return Value:
Quiet NaN if this object or the other object is NaN, or 0 if both objects have the same value, or -1 if this object is less than the other value, or 1 if this object is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public PeterO.Numbers.EDecimal Copy();
Creates a copy of this arbitrary-precision binary number.
Return Value:
An arbitrary-precision decimal floating-point number.
public PeterO.Numbers.EDecimal CopySign( PeterO.Numbers.EDecimal other);
Returns a number with the same value as this one, but copying the sign (positive or negative) of another number. (This method is similar to the “copy-sign” operation in the General Decimal Arithmetic Specification, except this method does not necessarily return a copy of this object.).
Parameters:
- other: A number whose sign will be copied.
Return Value:
An arbitrary-precision decimal number.
Exceptions:
- System.ArgumentNullException: The parameter other is null.
public static PeterO.Numbers.EDecimal Create( int mantissaSmall, int exponentSmall);
Returns a number with the value exponent*10^significand
.
Parameters:
-
mantissaSmall: Desired value for the significand.
-
exponentSmall: Desired value for the exponent.
Return Value:
An arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal Create( long mantissaLong, int exponentSmall);
Creates a number with the value exponent*10^significand
.
Parameters:
-
mantissaLong: Desired value for the significand.
-
exponentSmall: Desired value for the exponent.
Return Value:
An arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal Create( long mantissaLong, long exponentLong);
Creates a number with the value exponent*10^significand
.
Parameters:
-
mantissaLong: Desired value for the significand.
-
exponentLong: Desired value for the exponent.
Return Value:
An arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal Create( PeterO.Numbers.EInteger mantissa, int exponentSmall);
Creates a number with the value exponent*10^significand
.
Parameters:
-
mantissa: Desired value for the significand.
-
exponentSmall: Desired value for the exponent.
Return Value:
An arbitrary-precision decimal number.
Exceptions:
- System.ArgumentNullException: The parameter mantissa is null.
public static PeterO.Numbers.EDecimal Create( PeterO.Numbers.EInteger mantissa, long exponentLong);
Creates a number with the value exponent*10^significand
.
Parameters:
-
mantissa: Desired value for the significand.
-
exponentLong: Desired value for the exponent.
Return Value:
An arbitrary-precision decimal number.
Exceptions:
- System.ArgumentNullException: The parameter mantissa is null.
public static PeterO.Numbers.EDecimal Create( PeterO.Numbers.EInteger mantissa, PeterO.Numbers.EInteger exponent);
Creates a number with the value exponent*10^significand
.
Parameters:
-
mantissa: Desired value for the significand.
-
exponent: Desired value for the exponent.
Return Value:
An arbitrary-precision decimal number.
Exceptions:
- System.ArgumentNullException: The parameter mantissa or exponent is null.
public static PeterO.Numbers.EDecimal CreateNaN( PeterO.Numbers.EInteger diag, bool signaling, bool negative, PeterO.Numbers.EContext ctx);
Creates a not-a-number arbitrary-precision decimal number.
Parameters:
-
diag: An integer, 0 or greater, to use as diagnostic information associated with this object. If none is needed, should be zero. To get the diagnostic information from another arbitrary-precision decimal floating-point number, use that object’s
UnsignedMantissa
property. -
signaling: Whether the return value will be signaling (true) or quiet (false).
-
negative: Whether the return value is negative.
-
ctx: An arithmetic context to control the precision (in decimal digits) of the diagnostic information. The rounding and exponent range of this context will be ignored. Can be null. The only flag that can be signaled in this context is FlagInvalid, which happens if diagnostic information needs to be truncated and too much memory is required to do so.
Return Value:
An arbitrary-precision decimal number.
Exceptions:
- System.ArgumentNullException: The parameter diag is null or is less than 0.
public static PeterO.Numbers.EDecimal CreateNaN( PeterO.Numbers.EInteger diag);
Creates a not-a-number arbitrary-precision decimal number.
Parameters:
- diag: An integer, 0 or greater, to use as diagnostic information associated with this object. If none is needed, should be zero. To get the diagnostic information from another arbitrary-precision decimal floating-point number, use that object’s
UnsignedMantissa
property.
Return Value:
A quiet not-a-number.
public PeterO.Numbers.EDecimal Decrement();
Returns one subtracted from this arbitrary-precision decimal number.
Return Value:
The given arbitrary-precision decimal number minus one.
public PeterO.Numbers.EDecimal Divide( int intValue);
Divides this arbitrary-precision decimal floating-point number by a 32-bit signed integer and returns the result; returns NaN instead if the result would have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, and 2/3); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.
Parameters:
- intValue: A 32-bit signed integer, the divisor, to divide this object by.
Return Value:
The result of dividing this arbitrary-precision decimal floating-point number by a 32-bit signed integer. Returns infinity if the divisor (this arbitrary-precision decimal floating-point number) is 0 and the dividend (the other 32-bit signed integer) is nonzero. Returns not-a-number (NaN) if the divisor and the dividend are 0. Returns NaN if the result can’t be exact because it would have a nonterminating decimal expansion (examples include 1 divided by any multiple of 3, such as 1/3 or 1/12). If this is not desired, use DivideToExponent instead, or use the Divide overload that takes an EContext
(such as EContext.Decimal128
) instead.
public PeterO.Numbers.EDecimal Divide( long longValue);
Divides this arbitrary-precision decimal floating-point number by a 64-bit signed integer and returns the result; returns NaN instead if the result would have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, and 2/3); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.
Parameters:
- longValue: The parameter longValue is a 64-bit signed integer.
Return Value:
The result of dividing this arbitrary-precision decimal floating-point number by a 64-bit signed integer. Returns infinity if the divisor (this arbitrary-precision decimal floating-point number) is 0 and the dividend (the other 64-bit signed integer) is nonzero. Returns not-a-number (NaN) if the divisor and the dividend are 0. Returns NaN if the result can’t be exact because it would have a nonterminating decimal expansion (examples include 1 divided by any multiple of 3, such as 1/3 or 1/12). If this is not desired, use DivideToExponent instead, or use the Divide overload that takes an EContext
(such as EContext.Decimal128
) instead.
public PeterO.Numbers.EDecimal Divide( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The result of dividing this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number. Signals FlagDivideByZero and returns infinity if the divisor (this arbitrary-precision decimal floating-point number) is 0 and the dividend (the other arbitrary-precision decimal floating-point number) is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0; or, either ctx is null or ctx ‘s precision is 0, and the result would have a nonterminating decimal expansion (examples include 1 divided by any multiple of 3, such as 1/3 or 1/12); or, the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal Divide( PeterO.Numbers.EDecimal divisor);
Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result; returns NaN instead if the result would have a nonterminating decimal expansion (including 1/3, 1/12, 1/7, and 2/3); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.
Parameters:
- divisor: The number to divide by.
Return Value:
The result of dividing this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number. Returns infinity if the divisor (this arbitrary-precision decimal floating-point number) is 0 and the dividend (the other arbitrary-precision decimal floating-point number) is nonzero. Returns not-a-number (NaN) if the divisor and the dividend are 0. Returns NaN if the result can’t be exact because it would have a nonterminating decimal expansion (examples include 1 divided by any multiple of 3, such as 1/3 or 1/12). If this is not desired, use DivideToExponent instead, or use the Divide overload that takes an EContext
(such as EContext.Decimal128
) instead.
### DivideAndRemainderNaturalScale
public PeterO.Numbers.EDecimal[] DivideAndRemainderNaturalScale( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Obsolete. Renamed to DivRemNaturalScale.
Calculates the quotient and remainder using the DivideToIntegerNaturalScale and the formula in RemainderNaturalScale.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only in the division portion of the remainder calculation; as a result, it’s possible for the remainder to have a higher precision than given in this context. Flags will be set on the specified context only if the context’s
HasFlags
is true and the integer part of the division result doesn’t fit the precision and exponent range without rounding. Can be null, in which the precision is unlimited and no additional rounding, other than the rounding down to an integer after division, is needed.
Return Value:
A 2 element array consisting of the quotient and remainder in that order.
### DivideAndRemainderNaturalScale
public PeterO.Numbers.EDecimal[] DivideAndRemainderNaturalScale( PeterO.Numbers.EDecimal divisor);
Obsolete. Renamed to DivRemNaturalScale.
Calculates the quotient and remainder using the DivideToIntegerNaturalScale and the formula in RemainderNaturalScale.
Parameters:
- divisor: The number to divide by.
Return Value:
A 2 element array consisting of the quotient and remainder in that order.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, int desiredExponentInt, PeterO.Numbers.EContext ctx);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 32-bit signed integer) to the result, using the half-even rounding mode.
Parameters:
-
divisor: The number to divide by.
-
desiredExponentInt: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
-
ctx: An arithmetic context object to control the rounding mode to use if the result must be scaled down to have the same exponent as this value. If the precision given in the context is other than 0, calls the Quantize method with both arguments equal to the result of the operation (and can signal FlagInvalid and return NaN if the result doesn’t fit the specified precision). If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the context defines an exponent range and the desired exponent is outside that range. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, int desiredExponentInt, PeterO.Numbers.ERounding rounding);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 32-bit signed integer) to the result, using the half-even rounding mode.
Parameters:
-
divisor: The number to divide by.
-
desiredExponentInt: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
-
rounding: The rounding mode to use if the result must be scaled down to have the same exponent as this value.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, int desiredExponentInt);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 32-bit signed integer) to the result, using the half-even rounding mode.
Parameters:
-
divisor: The number to divide by.
-
desiredExponentInt: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, long desiredExponentSmall, PeterO.Numbers.EContext ctx);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.
Parameters:
-
divisor: The number to divide by.
-
desiredExponentSmall: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
-
ctx: An arithmetic context object to control the rounding mode to use if the result must be scaled down to have the same exponent as this value. If the precision given in the context is other than 0, calls the Quantize method with both arguments equal to the result of the operation (and can signal FlagInvalid and return NaN if the result doesn’t fit the specified precision). If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the context defines an exponent range and the desired exponent is outside that range. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, long desiredExponentSmall, PeterO.Numbers.ERounding rounding);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.
Parameters:
-
divisor: The number to divide by.
-
desiredExponentSmall: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
-
rounding: The rounding mode to use if the result must be scaled down to have the same exponent as this value.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, long desiredExponentSmall);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent (expressed as a 64-bit signed integer) to the result, using the half-even rounding mode.
Parameters:
-
divisor: The number to divide by.
-
desiredExponentSmall: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EInteger desiredExponent, PeterO.Numbers.ERounding rounding);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.
Parameters:
-
divisor: The number to divide by.
-
desiredExponent: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
-
rounding: The rounding mode to use if the result must be scaled down to have the same exponent as this value.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Returns not-a-number (NaN) if the divisor and the dividend are 0. Returns NaN if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EInteger exponent, PeterO.Numbers.EContext ctx);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result.
Parameters:
-
divisor: The number to divide by.
-
exponent: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
-
ctx: An arithmetic context object to control the rounding mode to use if the result must be scaled down to have the same exponent as this value. If the precision given in the context is other than 0, calls the Quantize method with both arguments equal to the result of the operation (and can signal FlagInvalid and return NaN if the result doesn’t fit the specified precision). If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the context defines an exponent range and the desired exponent is outside that range. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal DivideToExponent( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EInteger exponent);
Divides two arbitrary-precision decimal numbers, and gives a particular exponent to the result, using the half-even rounding mode.
Parameters:
-
divisor: The number to divide by.
-
exponent: The desired exponent. A negative number places the cutoff point to the right of the usual decimal point (so a negative number means the number of decimal places to round to). A positive number places the cutoff point to the left of the usual decimal point.
Return Value:
The quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0.
### DivideToIntegerNaturalScale
public PeterO.Numbers.EDecimal DivideToIntegerNaturalScale( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Divides this object by another object, and returns the integer part of the result (which is initially rounded down), with the preferred exponent set to this value’s exponent minus the divisor’s exponent.
Parameters:
-
divisor: The parameter divisor is an arbitrary-precision decimal floating-point number.
-
ctx: The parameter ctx is an EContext object.
Return Value:
The integer part of the quotient of the two objects. Signals FlagInvalid and returns not-a-number (NaN) if the return value would overflow the exponent range. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
### DivideToIntegerNaturalScale
public PeterO.Numbers.EDecimal DivideToIntegerNaturalScale( PeterO.Numbers.EDecimal divisor);
Divides two arbitrary-precision decimal numbers, and returns the integer part of the result, rounded down, with the preferred exponent set to this value’s exponent minus the divisor’s exponent.
Parameters:
- divisor: The number to divide by.
Return Value:
The integer part of the quotient of the two objects. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0.
public PeterO.Numbers.EDecimal DivideToIntegerZeroScale( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Divides this object by another object, and returns the integer part of the result, with the exponent set to 0.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision. The rounding and exponent range settings of this context are ignored. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited.
Return Value:
The integer part of the quotient of the two objects. The exponent will be set to 0. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0, or if the result doesn’t fit the specified precision.
public PeterO.Numbers.EDecimal DivideToSameExponent( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.ERounding rounding);
Divides this object by another decimal number and returns a result with the same exponent as this object (the dividend).
Parameters:
-
divisor: The number to divide by.
-
rounding: The rounding mode to use if the result must be scaled down to have the same exponent as this value.
Return Value:
The quotient of the two numbers. Signals FlagDivideByZero and returns infinity if the divisor is 0 and the dividend is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0. Signals FlagInvalid and returns not-a-number (NaN) if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal[] DivRemNaturalScale( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns a two-item array containing the result of the division and the remainder, in that order. The result of division is calculated as though by DivideToIntegerNaturalScale
, and the remainder is calculated as though by RemainderNaturalScale
.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only in the division portion of the remainder calculation; as a result, it’s possible for the remainder to have a higher precision than given in this context. Flags will be set on the specified context only if the context’s
HasFlags
is true and the integer part of the division result doesn’t fit the precision and exponent range without rounding. Can be null, in which the precision is unlimited and no additional rounding, other than the rounding down to an integer after division, is needed.
Return Value:
An array of two items: the first is the result of the division as an arbitrary-precision decimal floating-point number, and the second is the remainder as an arbitrary-precision decimal floating-point number. The result of division is the result of the method on the two operands, and the remainder is the result of the Remainder method on the two operands.
public PeterO.Numbers.EDecimal[] DivRemNaturalScale( PeterO.Numbers.EDecimal divisor);
Divides this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns a two-item array containing the result of the division and the remainder, in that order. The result of division is calculated as though by DivideToIntegerNaturalScale
, and the remainder is calculated as though by RemainderNaturalScale
.
Parameters:
- divisor: The number to divide by.
Return Value:
An array of two items: the first is the result of the division as an arbitrary-precision decimal floating-point number, and the second is the remainder as an arbitrary-precision decimal floating-point number. The result of division is the result of the method on the two operands, and the remainder is the result of the Remainder method on the two operands.
public override bool Equals( object obj);
Determines whether this object’s significand, exponent, and properties are equal to those of another object and that other object is an arbitrary-precision decimal number. Not-a-number values are considered equal if the rest of their properties are equal.
Parameters:
- obj: The parameter obj is an arbitrary object.
Return Value:
true
if the objects are equal; otherwise, false
. In this method, two objects are not equal if they don’t have the same type or if one is null and the other isn’t.
public sealed bool Equals( PeterO.Numbers.EDecimal other);
Determines whether this object’s significand, exponent, and properties are equal to those of another object. Not-a-number values are considered equal if the rest of their properties are equal.
Parameters:
- other: An arbitrary-precision decimal number.
Return Value:
true
if this object’s significand and exponent are equal to those of another object; otherwise, false
.
public PeterO.Numbers.EDecimal Exp( PeterO.Numbers.EContext ctx);
Finds e (the base of natural logarithms) raised to the power of this object’s value.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the exponential function’s results are generally not exact. (Unlike in the General Decimal Arithmetic Specification, any rounding mode is allowed.).
Return Value:
Exponential of this object. If this object’s value is 1, returns an approximation to “ e” within the specified precision. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
public PeterO.Numbers.EDecimal ExpM1( PeterO.Numbers.EContext ctx);
Finds e (the base of natural logarithms) raised to the power of this object’s value, and subtracts the result by 1 and returns the final result, in a way that avoids loss of precision if the true result is very close to 0.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the exponential function’s results are generally not exact. (Unlike in the General Binary Arithmetic Specification, any rounding mode is allowed.).
Return Value:
Exponential of this object, minus 1. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
public static PeterO.Numbers.EDecimal FromBoolean( bool boolValue);
Converts a Boolean value (true or false) to an arbitrary-precision decimal number.
Parameters:
- boolValue: Either true or false.
Return Value:
The number 1 if boolValue is true; otherwise, 0.
public static PeterO.Numbers.EDecimal FromByte( byte inputByte);
Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.
Parameters:
- inputByte: The number to convert as a byte (from 0 to 255).
Return Value:
This number’s value as an arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal FromDecimal( decimal dec);
Converts a decimal
under the Common Language Infrastructure (see "Forms of numbers"“Forms of numbers” ) to an arbitrary-precision decimal.
Parameters:
- dec: A
decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
Return Value:
An arbitrary-precision decimal floating-point number.
public static PeterO.Numbers.EDecimal FromDouble( double dbl);
Creates an arbitrary-precision decimal number from a 64-bit binary floating-point number. This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the floating point number to a string first. Remember, though, that the exact value of a 64-bit binary floating-point number is not always the value that results when passing a literal decimal number (for example, calling EDecimal.FromDouble(0.1)
), since not all decimal numbers can be converted to exact binary numbers (in the example given, the resulting arbitrary-precision decimal will be the value of the closest “double” to 0.1, not 0.1 exactly). To create an arbitrary-precision decimal number from a decimal value, use FromString instead in most cases (for example: EDecimal.FromString("0.1")
). The input value can be a not-a-number (NaN) value (such as Double.NaN
); however, NaN values have multiple forms that are equivalent for many applications’ purposes, and Double.NaN
is only one of these equivalent forms. In fact, EDecimal.FromDouble(Double.NaN)
could produce an object that is represented differently between DotNet and Java, because Double.NaN
may have a different form in DotNet and Java (for example, the NaN value’s sign may be negative in DotNet, but positive in Java). Use IsNaN()
to determine whether an object from this class stores a NaN value of any form.
Parameters:
- dbl: The parameter dbl is a 64-bit floating-point number.
Return Value:
An arbitrary-precision decimal number with the same value as dbl .
public static PeterO.Numbers.EDecimal FromDoubleBits( long dblBits);
Creates an arbitrary-precision decimal number from a 64-bit binary floating-point number, encoded in the IEEE 754 binary64 format. This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the floating point number to a string first. Remember, though, that the exact value of a 64-bit binary floating-point number is not always the value that results when passing a literal decimal number, since not all decimal numbers can be converted to exact binary numbers (in the example given, the resulting arbitrary-precision decimal will be the value of the closest “double” to 0.1, not 0.1 exactly). To create an arbitrary-precision decimal number from a decimal value, use FromString instead in most cases.
Parameters:
- dblBits: The parameter dblBits is a 64-bit signed integer.
Return Value:
An arbitrary-precision decimal number with the same value as dblBits .
public static PeterO.Numbers.EDecimal FromEFloat( PeterO.Numbers.EFloat bigfloat);
Creates an arbitrary-precision decimal number from an arbitrary-precision binary floating-point number.
Parameters:
- bigfloat: An arbitrary-precision binary floating-point number.
Return Value:
An arbitrary-precision decimal number.
Exceptions:
- System.ArgumentNullException: The parameter bigfloat is null.
public static PeterO.Numbers.EDecimal FromEInteger( PeterO.Numbers.EInteger bigint);
Converts an arbitrary-precision integer to an arbitrary precision decimal.
Parameters:
- bigint: An arbitrary-precision integer.
Return Value:
An arbitrary-precision decimal number with the exponent set to 0.
public static PeterO.Numbers.EDecimal FromExtendedFloat( PeterO.Numbers.EFloat ef);
Obsolete. Renamed to FromEFloat.
Converts an arbitrary-precision binary floating-point number to an arbitrary precision decimal.
Parameters:
- ef: An arbitrary-precision binary floating-point number.
Return Value:
An arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal FromHalfBits( short value);
Creates a decimal floating-point number from a binary floating-point number encoded in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number). This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the floating point number to a string first.
Parameters:
- value: A binary floating-point number encoded in the IEEE 754 binary16 format.
Return Value:
A decimal floating-point number with the same floating-point value as value .
public static PeterO.Numbers.EDecimal FromInt16( short inputInt16);
Converts a 16-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputInt16: The number to convert as a 16-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal FromInt32( int valueSmaller);
Creates an arbitrary-precision decimal number from a 32-bit signed integer.
Parameters:
- valueSmaller: The parameter valueSmaller is a 32-bit signed integer.
Return Value:
An arbitrary-precision decimal number with the exponent set to 0.
public static PeterO.Numbers.EDecimal FromInt64( long valueSmall);
Creates an arbitrary-precision decimal number from a 64-bit signed integer.
Parameters:
- valueSmall: The parameter valueSmall is a 64-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision decimal number with the exponent set to 0.
public static PeterO.Numbers.EDecimal FromInt64AsUnsigned( long longerValue);
Converts an unsigned integer expressed as a 64-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- longerValue: A 64-bit signed integer. If this value is 0 or greater, the return value will represent it. If this value is less than 0, the return value will store 2^64 plus this value instead.
Return Value:
An arbitrary-precision decimal number with the exponent set to 0. If longerValue is 0 or greater, the return value will represent it. If longerValue is less than 0, the return value will store 2^64 plus this value instead.
public static PeterO.Numbers.EDecimal FromSByte( sbyte inputSByte);
This API is not CLS-compliant.
Converts an 8-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputSByte: The number to convert as an 8-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal FromSingle( float flt);
Creates an arbitrary-precision decimal number from a 32-bit binary floating-point number. This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the floating point number to a string first. Remember, though, that the exact value of a 32-bit binary floating-point number is not always the value that results when passing a literal decimal number (for example, calling EDecimal.FromSingle(0.1f)
), since not all decimal numbers can be converted to exact binary numbers (in the example given, the resulting arbitrary-precision decimal will be the the value of the closest “float” to 0.1, not 0.1 exactly). To create an arbitrary-precision decimal number from a decimal value, use FromString instead in most cases (for example: EDecimal.FromString("0.1")
). The input value can be a not-a-number (NaN) value (such as Single.NaN
in DotNet or Float.NaN in Java); however, NaN values have multiple forms that are equivalent for many applications’ purposes, and Single.NaN
/ Float.NaN
is only one of these equivalent forms. In fact, EDecimal.FromSingle(Single.NaN)
or EDecimal.FromSingle(Float.NaN)
could produce an object that is represented differently between DotNet and Java, because Single.NaN
/ Float.NaN
may have a different form in DotNet and Java (for example, the NaN value’s sign may be negative in DotNet, but positive in Java). Use IsNaN()
to determine whether an object from this class stores a NaN value of any form.
Parameters:
- flt: The parameter flt is a 32-bit binary floating-point number.
Return Value:
An arbitrary-precision decimal number with the same value as flt .
public static PeterO.Numbers.EDecimal FromSingleBits( int value);
Creates an arbitrary-precision decimal number from a 32-bit binary floating-point number encoded in the IEEE 754 binary32 format. This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the floating point number to a string first. Remember, though, that the exact value of a 32-bit binary floating-point number is not always the value that results when passing a literal decimal number, since not all decimal numbers can be converted to exact binary numbers (in the example given, the resulting arbitrary-precision decimal will be the the value of the closest “float” to 0.1, not 0.1 exactly). To create an arbitrary-precision decimal number from a decimal value, use FromString instead in most cases.
Parameters:
- value: A 32-bit binary floating-point number encoded in the IEEE 754 binary32 format.
Return Value:
An arbitrary-precision decimal number with the same value as value .
public static PeterO.Numbers.EDecimal FromString( byte[] bytes, int offset, int length, PeterO.Numbers.EContext ctx);
Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number. Each byte in the sequence has to be a code point in the Basic Latin range (0x00 to 0x7f or U+0000 to U+007F) of the Unicode Standard.
The format of the sequence generally consists of:
-
An optional plus sign (“+” , U+002B) or minus sign (“-“, U+002D) (if the minus sign, the value is negative.)
-
One or more digits, with a single optional decimal point (“.”, U+002E) before or after those digits or between two of them. These digits may begin with any number of zeros.
-
Optionally, “E”/”e” followed by an optional (positive exponent) or “-“ (negative exponent) and followed by one or more digits specifying the exponent (these digits may begin with any number of zeros).
The sequence can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN” /”-NaN”) followed by any number of digits (these digits may begin with any number of zeros), or signaling NaN (“sNaN” /”-sNaN”) followed by any number of digits (these digits may begin with any number of zeros), all where the letters can be any combination of basic uppercase and basic lowercase letters.
All characters mentioned earlier are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U+0030 to U+0039). The sequence is not allowed to contain white space characters, including spaces.
Parameters:
-
bytes: A sequence of bytes (interpreted as text), a portion of which represents a number.
-
offset: An index starting at 0 showing where the desired portion of bytes begins.
-
length: The length, in code units, of the desired portion of bytes (but not more than bytes ‘s length).
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. Note that providing a context is often much faster than creating the EDecimal without a context then callingRoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of bytes (interpreted as text).
Exceptions:
-
System.ArgumentNullException: The parameter bytes is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than bytes ‘s length, or bytes ‘s length minus offset is less than length .
public static PeterO.Numbers.EDecimal FromString( byte[] bytes, int offset, int length);
Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number. See FromString(String, int, int, EContext)
for more information. Note that calling the overload that takes an EContext is often much faster than creating the EDecimal then calling RoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Parameters:
-
bytes: A sequence that represents a number.
-
offset: An index starting at 0 showing where the desired portion of bytes begins.
-
length: The length, in bytes, of the desired portion of bytes (but not more than bytes ‘s length).
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of bytes (interpreted as text).
Exceptions:
-
System.FormatException: The parameter bytes is not a correctly formatted number sequence.
-
System.ArgumentNullException: The parameter bytes is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than bytes ‘s length, or bytes ‘s length minus offset is less than length .
public static PeterO.Numbers.EDecimal FromString( byte[] bytes, PeterO.Numbers.EContext ctx);
Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number. See FromString(String, int, int, EContext)
for more information.
Parameters:
-
bytes: A sequence of bytes (interpreted as text) that represents a number.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. Note that providing a context is often much faster than creating the EDecimal without a context then callingRoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of bytes (interpreted as text).
Exceptions:
- System.ArgumentNullException: The parameter bytes is null.
public static PeterO.Numbers.EDecimal FromString( byte[] bytes);
Creates an arbitrary-precision decimal number from a sequence of bytes (interpreted as text) that represents a number. See FromString(String, int, int, EContext)
for more information. Note that calling the overload that takes an EContext is often much faster than creating the EDecimal then calling RoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Parameters:
- bytes: A sequence that represents a number.
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of bytes (interpreted as text).
Exceptions:
- System.FormatException: The parameter bytes is not a correctly formatted number sequence.
public static PeterO.Numbers.EDecimal FromString( char[] chars, int offset, int length, PeterO.Numbers.EContext ctx);
Creates an arbitrary-precision decimal number from a sequence of char
s that represents a number.
The format of the sequence generally consists of:
-
An optional plus sign (“+” , U+002B) or minus sign (“-“, U+002D) (if the minus sign, the value is negative.)
-
One or more digits, with a single optional decimal point (“.”, U+002E) before or after those digits or between two of them. These digits may begin with any number of zeros.
-
Optionally, “E”/”e” followed by an optional (positive exponent) or “-“ (negative exponent) and followed by one or more digits specifying the exponent (these digits may begin with any number of zeros).
The sequence can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN” /”-NaN”) followed by any number of digits (these digits may begin with any number of zeros), or signaling NaN (“sNaN” /”-sNaN”) followed by any number of digits (these digits may begin with any number of zeros), all where the letters can be any combination of basic uppercase and basic lowercase letters.
All characters mentioned earlier are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U+0030 to U+0039). The sequence is not allowed to contain white space characters, including spaces.
Parameters:
-
chars: A sequence of
char
s, a portion of which represents a number. -
offset: An index starting at 0 showing where the desired portion of chars begins.
-
length: The length, in code units, of the desired portion of chars (but not more than chars ‘s length).
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. Note that providing a context is often much faster than creating the EDecimal without a context then callingRoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of char
s.
Exceptions:
-
System.ArgumentNullException: The parameter chars is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than chars ‘s length, or chars ‘s length minus offset is less than length .
public static PeterO.Numbers.EDecimal FromString( char[] chars, int offset, int length);
Creates an arbitrary-precision decimal number from a sequence of char
s that represents a number. See FromString(String, int, int, EContext)
for more information. Note that calling the overload that takes an EContext is often much faster than creating the EDecimal then calling RoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Parameters:
-
chars: A sequence that represents a number.
-
offset: An index starting at 0 showing where the desired portion of chars begins.
-
length: The length, in code units, of the desired portion of chars (but not more than chars ‘s length).
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of char
s.
Exceptions:
-
System.FormatException: The parameter chars is not a correctly formatted number sequence.
-
System.ArgumentNullException: The parameter chars is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than chars ‘s length, or chars ‘s length minus offset is less than length .
public static PeterO.Numbers.EDecimal FromString( char[] chars, PeterO.Numbers.EContext ctx);
Creates an arbitrary-precision decimal number from a sequence of char
s that represents a number. See FromString(String, int, int, EContext)
for more information.
Parameters:
-
chars: A sequence of
char
s that represents a number. -
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. Note that providing a context is often much faster than creating the EDecimal without a context then callingRoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of char
s.
Exceptions:
- System.ArgumentNullException: The parameter chars is null.
public static PeterO.Numbers.EDecimal FromString( char[] chars);
Creates an arbitrary-precision decimal number from a sequence of char
s that represents a number. See FromString(String, int, int, EContext)
for more information. Note that calling the overload that takes an EContext is often much faster than creating the EDecimal then calling RoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Parameters:
- chars: A sequence that represents a number.
Return Value:
An arbitrary-precision decimal number with the same value as the specified sequence of char
s.
Exceptions:
- System.FormatException: The parameter chars is not a correctly formatted number sequence.
public static PeterO.Numbers.EDecimal FromString( string str, int offset, int length, PeterO.Numbers.EContext ctx);
Creates an arbitrary-precision decimal number from a text string that represents a number.
The format of the string generally consists of:
-
An optional plus sign (“+” , U+002B) or minus sign (“-“, U+002D) (if the minus sign, the value is negative.)
-
One or more digits, with a single optional decimal point (“.”, U+002E) before or after those digits or between two of them. These digits may begin with any number of zeros.
-
Optionally, “E”/”e” followed by an optional (positive exponent) or “-“ (negative exponent) and followed by one or more digits specifying the exponent (these digits may begin with any number of zeros).
The string can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN” /”-NaN”) followed by any number of digits (these digits may begin with any number of zeros), or signaling NaN (“sNaN” /”-sNaN”) followed by any number of digits (these digits may begin with any number of zeros), all where the letters can be any combination of basic uppercase and basic lowercase letters.
All characters mentioned earlier are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U+0030 to U+0039). The string is not allowed to contain white space characters, including spaces.
Parameters:
-
str: A text string, a portion of which represents a number.
-
offset: An index starting at 0 showing where the desired portion of str begins.
-
length: The length, in code units, of the desired portion of str (but not more than str ‘s length).
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. Note that providing a context is often much faster than creating the EDecimal without a context then callingRoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Return Value:
An arbitrary-precision decimal number with the same value as the specified string.
Exceptions:
-
System.ArgumentNullException: The parameter str is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than str ‘s length, or str ‘s length minus offset is less than length .
public static PeterO.Numbers.EDecimal FromString( string str, int offset, int length);
Creates an arbitrary-precision decimal number from a text string that represents a number. See FromString(String, int,
int, EContext)
for more information. Note that calling the overload that takes an EContext is often much faster than creating the EDecimal then calling RoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Parameters:
-
str: A string that represents a number.
-
offset: An index starting at 0 showing where the desired portion of str begins.
-
length: The length, in code units, of the desired portion of str (but not more than str ‘s length).
Return Value:
An arbitrary-precision decimal number with the same value as the specified string.
Exceptions:
-
System.FormatException: The parameter str is not a correctly formatted number string.
-
System.ArgumentNullException: The parameter str is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than str ‘s length, or str ‘s length minus offset is less than length .
public static PeterO.Numbers.EDecimal FromString( string str, PeterO.Numbers.EContext ctx);
Creates an arbitrary-precision decimal number from a text string that represents a number. See FromString(String, int,
int, EContext)
for more information.
Parameters:
-
str: A string that represents a number.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. Note that providing a context is often much faster than creating the EDecimal without a context then callingRoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Return Value:
An arbitrary-precision decimal number with the same value as the specified string.
Exceptions:
- System.ArgumentNullException: The parameter str is null.
public static PeterO.Numbers.EDecimal FromString( string str);
Creates an arbitrary-precision decimal number from a text string that represents a number. See FromString(String, int,
int, EContext)
for more information. Note that calling the overload that takes an EContext is often much faster than creating the EDecimal then calling RoundToPrecision
on that EDecimal, especially if the context specifies a precision limit and exponent range.
Parameters:
- str: A string that represents a number.
Return Value:
An arbitrary-precision decimal number with the same value as the specified string.
Exceptions:
- System.FormatException: The parameter str is not a correctly formatted number string.
public static PeterO.Numbers.EDecimal FromUInt16( ushort inputUInt16);
This API is not CLS-compliant.
Converts a 16-bit unsigned integer to an arbitrary-precision decimal number.
Parameters:
- inputUInt16: The number to convert as a 16-bit unsigned integer.
Return Value:
This number’s value as an arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal FromUInt32( uint inputUInt32);
This API is not CLS-compliant.
Converts a 32-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputUInt32: The number to convert as a 32-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal FromUInt64( ulong inputUInt64);
This API is not CLS-compliant.
Converts a 64-bit unsigned integer to an arbitrary-precision decimal number.
Parameters:
- inputUInt64: The number to convert as a 64-bit unsigned integer.
Return Value:
This number’s value as an arbitrary-precision decimal number.
public override int GetHashCode();
Calculates this object’s hash code. No application or process IDs are used in the hash code calculation.
Return Value:
A 32-bit signed integer.
public PeterO.Numbers.EDecimal Increment();
Returns one added to this arbitrary-precision decimal number.
Return Value:
The given arbitrary-precision decimal number plus one.
public bool IsInfinity();
Gets a value indicating whether this object is positive or negative infinity.
Return Value:
true
if this object is positive or negative infinity; otherwise, false
.
public bool IsInteger();
Returns whether this object’s value is an integer.
Return Value:
true
if this object’s value is an integer; otherwise, false
.
public bool IsNaN();
Gets a value indicating whether this object is not a number (NaN).
Return Value:
true
if this object is not a number (NaN); otherwise, false
.
public bool IsNegativeInfinity();
Returns whether this object is negative infinity.
Return Value:
true
if this object is negative infinity; otherwise, false
.
public bool IsPositiveInfinity();
Returns whether this object is positive infinity.
Return Value:
true
if this object is positive infinity; otherwise, false
.
public bool IsQuietNaN();
Gets a value indicating whether this object is a quiet not-a-number value.
Return Value:
true
if this object is a quiet not-a-number value; otherwise, false
.
public bool IsSignalingNaN();
Gets a value indicating whether this object is a signaling not-a-number value.
Return Value:
true
if this object is a signaling not-a-number value; otherwise, false
.
public PeterO.Numbers.EDecimal Log( PeterO.Numbers.EContext ctx);
Finds the natural logarithm of this object, that is, the power (exponent) that e (the base of natural logarithms) must be raised to in order to equal this object’s value.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the ln function’s results are generally not exact. (Unlike in the General Decimal Arithmetic Specification, any rounding mode is allowed.).
Return Value:
Ln(this object). Signals the flag FlagInvalid and returns NaN if this object is less than 0 (the result would be a complex number with a real part equal to Ln of this object’s absolute value and an imaginary part equal to pi, but the return value is still NaN.). Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0). Signals no flags and returns negative infinity if this object’s value is 0.
public PeterO.Numbers.EDecimal Log10( PeterO.Numbers.EContext ctx);
Finds the base-10 logarithm of this object, that is, the power (exponent) that the number 10 must be raised to in order to equal this object’s value.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the ln function’s results are generally not exact. (Unlike in the General Decimal Arithmetic Specification, any rounding mode is allowed.).
Return Value:
Ln(this object)/Ln(10). Signals the flag FlagInvalid and returns not-a-number (NaN) if this object is less than 0. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
public PeterO.Numbers.EDecimal Log1P( PeterO.Numbers.EContext ctx);
Adds 1 to this object’s value and finds the natural logarithm of the result, in a way that avoids loss of precision when this object’s value is between 0 and 1.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the ln function’s results are generally not exact. (Unlike in the General Binary Arithmetic Specification, any rounding mode is allowed.).
Return Value:
Ln(1+(this object)). Signals the flag FlagInvalid and returns NaN if this object is less than -1 (the result would be a complex number with a real part equal to Ln of 1 plus this object’s absolute value and an imaginary part equal to pi, but the return value is still NaN.). Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0). Signals no flags and returns negative infinity if this object’s value is 0.
public PeterO.Numbers.EDecimal LogN( PeterO.Numbers.EDecimal baseValue, PeterO.Numbers.EContext ctx);
Finds the base-N logarithm of this object, that is, the power (exponent) that the number N must be raised to in order to equal this object’s value.
Parameters:
-
baseValue: The parameter baseValue is a Numbers.EDecimal object.
-
ctx: The parameter ctx is a Numbers.EContext object.
Return Value:
Ln(this object)/Ln(baseValue). Signals the flag FlagInvalid and returns not-a-number (NaN) if this object is less than 0. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
Exceptions:
- System.ArgumentNullException: The parameter baseValue is null.
public static PeterO.Numbers.EDecimal Max( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second, PeterO.Numbers.EContext ctx);
Gets the greater value between two decimal numbers.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
The larger value of the two numbers. If one is positive zero and the other is negative zero, returns the positive zero. If the two numbers are positive and have the same value, returns the one with the larger exponent. If the two numbers are negative and have the same value, returns the one with the smaller exponent.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal Max( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second);
Gets the greater value between two decimal numbers.
Parameters:
-
first: An arbitrary-precision decimal number.
-
second: Another arbitrary-precision decimal number.
Return Value:
The larger value of the two numbers. If one is positive zero and the other is negative zero, returns the positive zero. If the two numbers are positive and have the same value, returns the one with the larger exponent. If the two numbers are negative and have the same value, returns the one with the smaller exponent.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal MaxMagnitude( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second, PeterO.Numbers.EContext ctx);
Gets the greater value between two values, ignoring their signs. If the absolute values are equal, has the same effect as Max.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
The larger value of the two numbers, ignoring their signs.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal MaxMagnitude( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second);
Gets the greater value between two values, ignoring their signs. If the absolute values are equal, has the same effect as Max.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
Return Value:
The larger value of the two numbers, ignoring their signs.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal Min( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second, PeterO.Numbers.EContext ctx);
Gets the lesser value between two decimal numbers.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
The smaller value of the two numbers. If one is positive zero and the other is negative zero, returns the negative zero. If the two numbers are positive and have the same value, returns the one with the smaller exponent. If the two numbers are negative and have the same value, returns the one with the larger exponent.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal Min( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second);
Gets the lesser value between two decimal numbers.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
Return Value:
The smaller value of the two numbers. If one is positive zero and the other is negative zero, returns the negative zero. If the two numbers are positive and have the same value, returns the one with the smaller exponent. If the two numbers are negative and have the same value, returns the one with the larger exponent.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal MinMagnitude( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second, PeterO.Numbers.EContext ctx);
Gets the lesser value between two values, ignoring their signs. If the absolute values are equal, has the same effect as Min.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
The smaller value of the two numbers, ignoring their signs.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.EDecimal MinMagnitude( PeterO.Numbers.EDecimal first, PeterO.Numbers.EDecimal second);
Gets the lesser value between two values, ignoring their signs. If the absolute values are equal, has the same effect as Min.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
Return Value:
The smaller value of the two numbers, ignoring their signs.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public PeterO.Numbers.EDecimal MovePointLeft( int places, PeterO.Numbers.EContext ctx);
Returns a number similar to this number but with the decimal point moved to the left.
Parameters:
-
places: The number of decimal places to move the decimal point to the left. If this number is negative, instead moves the decimal point to the right by this number’s absolute value.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
A number whose exponent is decreased by places , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointLeft( int places);
Returns a number similar to this number but with the decimal point moved to the left.
Parameters:
- places: The number of decimal places to move the decimal point to the left. If this number is negative, instead moves the decimal point to the right by this number’s absolute value.
Return Value:
A number whose exponent is decreased by places , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointLeft( PeterO.Numbers.EInteger bigPlaces, PeterO.Numbers.EContext ctx);
Returns a number similar to this number but with the decimal point moved to the left.
Parameters:
-
bigPlaces: The number of decimal places to move the decimal point to the left. If this number is negative, instead moves the decimal point to the right by this number’s absolute value.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
A number whose exponent is decreased by bigPlaces , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointLeft( PeterO.Numbers.EInteger bigPlaces);
Returns a number similar to this number but with the decimal point moved to the left.
Parameters:
- bigPlaces: The number of decimal places to move the decimal point to the left. If this number is negative, instead moves the decimal point to the right by this number’s absolute value.
Return Value:
A number whose exponent is decreased by bigPlaces , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointRight( int places, PeterO.Numbers.EContext ctx);
Returns a number similar to this number but with the decimal point moved to the right.
Parameters:
-
places: The number of decimal places to move the decimal point to the right. If this number is negative, instead moves the decimal point to the left by this number’s absolute value.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
A number whose exponent is increased by places , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointRight( int places);
Returns a number similar to this number but with the decimal point moved to the right.
Parameters:
- places: The number of decimal places to move the decimal point to the right. If this number is negative, instead moves the decimal point to the left by this number’s absolute value.
Return Value:
A number whose exponent is increased by places , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointRight( PeterO.Numbers.EInteger bigPlaces, PeterO.Numbers.EContext ctx);
Returns a number similar to this number but with the decimal point moved to the right.
Parameters:
-
bigPlaces: The number of decimal places to move the decimal point to the right. If this number is negative, instead moves the decimal point to the left by this number’s absolute value.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
A number whose exponent is increased by bigPlaces , but not to more than 0.
public PeterO.Numbers.EDecimal MovePointRight( PeterO.Numbers.EInteger bigPlaces);
Returns a number similar to this number but with the decimal point moved to the right.
Parameters:
- bigPlaces: The number of decimal places to move the decimal point to the right. If this number is negative, instead moves the decimal point to the left by this number’s absolute value.
Return Value:
A number whose exponent is increased by bigPlaces , but not to more than 0.
public PeterO.Numbers.EDecimal Multiply( int intValue);
Multiplies this arbitrary-precision decimal floating-point number by a 32-bit signed integer and returns the result. The exponent for the result is this arbitrary-precision decimal floating-point number’s exponent plus the other 32-bit signed integer’s exponent.
Parameters:
- intValue: A 32-bit signed integer to multiply this object by.
Return Value:
The product of the two numbers, that is, this arbitrary-precision decimal floating-point number times a 32-bit signed integer.
public PeterO.Numbers.EDecimal Multiply( long longValue);
Multiplies this arbitrary-precision decimal floating-point number by a 64-bit signed integer and returns the result. The exponent for the result is this arbitrary-precision decimal floating-point number’s exponent plus the other 64-bit signed integer’s exponent.
Parameters:
- longValue: The parameter longValue is a 64-bit signed integer.
Return Value:
The product of the two numbers, that is, this arbitrary-precision decimal floating-point number times a 64-bit signed integer.
public PeterO.Numbers.EDecimal Multiply( PeterO.Numbers.EDecimal op, PeterO.Numbers.EContext ctx);
Multiplies this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.
Parameters:
-
op: Another decimal number.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
The product of the two numbers, that is, this arbitrary-precision decimal floating-point number times another arbitrary-precision decimal floating-point number.
public PeterO.Numbers.EDecimal Multiply( PeterO.Numbers.EDecimal otherValue);
Multiplies this arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result. The exponent for the result is this arbitrary-precision decimal floating-point number’s exponent plus the other arbitrary-precision decimal floating-point number’s exponent.
Parameters:
- otherValue: Another decimal number.
Return Value:
The product of the two numbers, that is, this arbitrary-precision decimal floating-point number times another arbitrary-precision decimal floating-point number.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public PeterO.Numbers.EDecimal MultiplyAndAdd( PeterO.Numbers.EDecimal multiplicand, PeterO.Numbers.EDecimal augend);
Multiplies by one decimal number, and then adds another decimal number.
Parameters:
-
multiplicand: The value to multiply.
-
augend: The value to add.
Return Value:
An arbitrary-precision decimal floating-point number.
public PeterO.Numbers.EDecimal MultiplyAndAdd( PeterO.Numbers.EDecimal op, PeterO.Numbers.EDecimal augend, PeterO.Numbers.EContext ctx);
Multiplies by one value, and then adds another value.
Parameters:
-
op: The value to multiply.
-
augend: The value to add.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. If the precision doesn’t indicate a simplified arithmetic, rounding and precision/exponent adjustment is done only once, namely, after multiplying and adding.
Return Value:
The result thisValue * multiplicand + augend.
public PeterO.Numbers.EDecimal MultiplyAndSubtract( PeterO.Numbers.EDecimal op, PeterO.Numbers.EDecimal subtrahend, PeterO.Numbers.EContext ctx);
Multiplies by one value, and then subtracts another value.
Parameters:
-
op: The value to multiply.
-
subtrahend: The value to subtract.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed. If the precision doesn’t indicate a simplified arithmetic, rounding and precision/exponent adjustment is done only once, namely, after multiplying and subtracting.
Return Value:
The result thisValue * multiplicand - subtrahend.
Exceptions:
- System.ArgumentNullException: The parameter op or subtrahend is null.
public PeterO.Numbers.EDecimal Negate( PeterO.Numbers.EContext context);
Returns an arbitrary-precision decimal number with the same value as this object but with the sign reversed.
Parameters:
- context: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
An arbitrary-precision decimal number. If this value is positive zero, returns positive zero. Signals FlagInvalid and returns quiet NaN if this value is signaling NaN.
public PeterO.Numbers.EDecimal Negate();
Gets an object with the same value as this one, but with the sign reversed.
Return Value:
An arbitrary-precision decimal number. If this value is positive zero, returns negative zero. Returns signaling NaN if this value is signaling NaN. (In this sense, this method is similar to the “copy-negate” operation in the General Decimal Arithmetic Specification, except this method does not necessarily return a copy of this object.).
public PeterO.Numbers.EDecimal NextMinus( PeterO.Numbers.EContext ctx);
Finds the largest value that’s smaller than the specified value.
Parameters:
- ctx: An arithmetic context object to control the precision and exponent range of the result. The rounding mode from this context is ignored. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags).
Return Value:
Returns the largest value that’s less than the specified value. Returns negative infinity if the result is negative infinity. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null, the precision is 0, or ctx has an unlimited exponent range.
public PeterO.Numbers.EDecimal NextPlus( PeterO.Numbers.EContext ctx);
Finds the smallest value that’s greater than the specified value.
Parameters:
- ctx: An arithmetic context object to control the precision and exponent range of the result. The rounding mode from this context is ignored. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags).
Return Value:
Returns the smallest value that’s greater than the specified value.Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null, the precision is 0, or ctx has an unlimited exponent range.
public PeterO.Numbers.EDecimal NextToward( PeterO.Numbers.EDecimal otherValue, PeterO.Numbers.EContext ctx);
Finds the next value that is closer to the other object’s value than this object’s value. Returns a copy of this value with the same sign as the other value if both values are equal.
Parameters:
-
otherValue: An arbitrary-precision decimal number that the return value will approach.
-
ctx: An arithmetic context object to control the precision and exponent range of the result. The rounding mode from this context is ignored. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags).
Return Value:
Returns the next value that is closer to the other object’ s value than this object’s value. Signals FlagInvalid and returns NaN if the parameter ctx is null, the precision is 0, or ctx has an unlimited exponent range.
public static PeterO.Numbers.EDecimal operator +( PeterO.Numbers.EDecimal bthis, PeterO.Numbers.EDecimal otherValue);
Adds an arbitrary-precision decimal floating-point number and another arbitrary-precision decimal floating-point number and returns the result.
Parameters:
-
bthis: The first arbitrary-precision decimal floating-point number.
-
otherValue: The second decimal binary floating-point number.
Return Value:
The sum of the two numbers, that is, an arbitrary-precision decimal floating-point number plus another arbitrary-precision decimal floating-point number.
Exceptions:
- System.ArgumentNullException: The parameter bthis or otherValue is null.
public static PeterO.Numbers.EDecimal operator --( PeterO.Numbers.EDecimal bthis);
Subtracts one from an arbitrary-precision decimal number.
Parameters:
- bthis: An arbitrary-precision decimal number.
Return Value:
The given arbitrary-precision decimal number minus one.
Exceptions:
- System.ArgumentNullException: The parameter bthis is null.
public static PeterO.Numbers.EDecimal operator /( PeterO.Numbers.EDecimal dividend, PeterO.Numbers.EDecimal divisor);
Divides this object by another decimal number and returns the result. When possible, the result will be exact.
Parameters:
-
dividend: The number that will be divided by the divisor.
-
divisor: The number to divide by.
Return Value:
The quotient of the two numbers. Returns infinity if the divisor is 0 and the dividend is nonzero. Returns not-a-number (NaN) if the divisor and the dividend are 0. Returns NaN if the result can’t be exact because it would have a nonterminating decimal expansion; examples include 1 divided by any multiple of 3, such as 1/3 or 1/12. If this is not desired, use DivideToExponent instead, or use the Divide overload that takes an EContext instead.
Exceptions:
- System.ArgumentNullException: The parameter dividend is null.
public static explicit operator byte( PeterO.Numbers.EDecimal input);
Converts an arbitrary-precision decimal number to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a byte (from 0 to 255).
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 255.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator decimal( PeterO.Numbers.EDecimal bigValue);
Converts an arbitrary-precision decimal’s value to a decimal
under the Common Language Infrastructure (see "Forms of numbers"“Forms of numbers” ), using the half-even rounding mode.
Parameters:
- bigValue: The parameter bigValue is an arbitrary-precision decimal floating-point number.
Return Value:
A decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator double( PeterO.Numbers.EDecimal bigValue);
Converts this value to its closest equivalent as a 64-bit floating-point number. The half-even rounding mode is used. If this value is a NaN, sets the high bit of the 64-bit floating point number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN. Unfortunately, in the.NET implementation, the return value of this method may be a quiet NaN even if a signaling NaN would otherwise be generated.
Parameters:
- bigValue: The value to convert to a 64-bit floating-point number.
Return Value:
The closest 64-bit floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 64-bit floating point number.
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator float( PeterO.Numbers.EDecimal bigValue);
Converts this value to its closest equivalent as a 32-bit floating-point number. The half-even rounding mode is used. If this value is a NaN, sets the high bit of the 32-bit floating point number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN. Unfortunately, in the.NET implementation, the return value of this method may be a quiet NaN even if a signaling NaN would otherwise be generated.
Parameters:
- bigValue: The number to convert as an arbitrary-precision decimal number.
Return Value:
The closest 32-bit binary floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 32-bit floating point number.
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator int( PeterO.Numbers.EDecimal input);
Converts an arbitrary-precision decimal number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a 32-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -2147483648 or greater than 2147483647.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator long( PeterO.Numbers.EDecimal input);
Converts an arbitrary-precision decimal number to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a 64-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -9223372036854775808 or greater than 9223372036854775807.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator PeterO.Numbers.EDecimal( bool boolValue);
Converts a Boolean value (true or false) to an arbitrary precision decimal.
Parameters:
- boolValue: Either true or false.
Return Value:
The number 1 if boolValue is true; otherwise, 0.
public static explicit operator PeterO.Numbers.EInteger( PeterO.Numbers.EDecimal bigValue);
Converts an arbitrary-precision decimal floating-point number to an arbitrary-precision integer. Any fractional part in this value will be discarded when converting to an arbitrary-precision integer.
Parameters:
- bigValue: The number to convert as an arbitrary-precision decimal.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN).
-
System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator sbyte( PeterO.Numbers.EDecimal input);
This API is not CLS-compliant.
Converts an arbitrary-precision decimal number to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to an 8-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -128 or greater than 127.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator short( PeterO.Numbers.EDecimal input);
Converts an arbitrary-precision decimal number to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a 16-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -32768 or greater than 32767.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator uint( PeterO.Numbers.EDecimal input);
This API is not CLS-compliant.
Converts an arbitrary-precision decimal number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a 32-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 4294967295.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator ulong( PeterO.Numbers.EDecimal input);
This API is not CLS-compliant.
Converts an arbitrary-precision decimal number to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a 64-bit unsigned integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 18446744073709551615.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator ushort( PeterO.Numbers.EDecimal input);
This API is not CLS-compliant.
Converts an arbitrary-precision decimal number to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision decimal number.
Return Value:
The value of input , truncated to a 16-bit unsigned integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 65535.
-
System.ArgumentNullException: The parameter input is null.
public static implicit operator PeterO.Numbers.EDecimal( byte inputByte);
Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.
Parameters:
- inputByte: The number to convert as a byte (from 0 to 255).
Return Value:
The value of inputByte as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( decimal dec);
Converts an arbitrary-precision decimal number to a decimal
under the Common Language Infrastructure (see "Forms of numbers"“Forms of numbers” ), using the half-even rounding mode.
Parameters:
- dec: The number to convert as an arbitrary-precision decimal floating-point number.
Return Value:
A decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
public static implicit operator PeterO.Numbers.EDecimal( int inputInt32);
Converts a 32-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputInt32: The number to convert as a 32-bit signed integer.
Return Value:
The value of inputInt32 as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( long inputInt64);
Converts a 64-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputInt64: The number to convert as a 64-bit signed integer.
Return Value:
The value of inputInt64 as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( PeterO.Numbers.EInteger eint);
Converts an arbitrary-precision integer to an arbitrary precision decimal.
Parameters:
- eint: An arbitrary-precision integer.
Return Value:
An arbitrary-precision decimal number with the exponent set to 0.
public static implicit operator PeterO.Numbers.EDecimal( sbyte inputSByte);
This API is not CLS-compliant.
Converts an 8-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputSByte: The number to convert as an 8-bit signed integer.
Return Value:
The value of inputSByte as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( short inputInt16);
Converts a 16-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputInt16: The number to convert as a 16-bit signed integer.
Return Value:
The value of inputInt16 as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( uint inputUInt32);
This API is not CLS-compliant.
Converts a 32-bit signed integer to an arbitrary-precision decimal number.
Parameters:
- inputUInt32: The number to convert as a 32-bit signed integer.
Return Value:
The value of inputUInt32 as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( ulong inputUInt64);
This API is not CLS-compliant.
Converts a 64-bit unsigned integer to an arbitrary-precision decimal number.
Parameters:
- inputUInt64: The number to convert as a 64-bit unsigned integer.
Return Value:
The value of inputUInt64 as an arbitrary-precision decimal number.
public static implicit operator PeterO.Numbers.EDecimal( ushort inputUInt16);
This API is not CLS-compliant.
Converts a 16-bit unsigned integer to an arbitrary-precision decimal number.
Parameters:
- inputUInt16: The number to convert as a 16-bit unsigned integer.
Return Value:
The value of inputUInt16 as an arbitrary-precision decimal number.
public static PeterO.Numbers.EDecimal operator ++( PeterO.Numbers.EDecimal bthis);
Adds one to an arbitrary-precision decimal number.
Parameters:
- bthis: An arbitrary-precision decimal number.
Return Value:
The given arbitrary-precision decimal number plus one.
Exceptions:
- System.ArgumentNullException: The parameter bthis is null.
public static PeterO.Numbers.EDecimal operator %( PeterO.Numbers.EDecimal dividend, PeterO.Numbers.EDecimal divisor);
Returns the remainder that would result when an arbitrary-precision decimal floating-point number is divided by another arbitrary-precision decimal floating-point number. The remainder is the number that remains when the absolute value of an arbitrary-precision decimal floating-point number is divided (as though by DivideToIntegerZeroScale) by the absolute value of the other arbitrary-precision decimal floating-point number; the remainder has the same sign (positive or negative) as this arbitrary-precision decimal floating-point number.
Parameters:
-
dividend: The number that will be divided by the divisor.
-
divisor: The number to divide by.
Return Value:
The remainder that would result when an arbitrary-precision decimal floating-point number is divided by another arbitrary-precision decimal floating-point number.
Exceptions:
- System.ArgumentNullException: The parameter dividend is null.
public static PeterO.Numbers.EDecimal operator *( PeterO.Numbers.EDecimal operand1, PeterO.Numbers.EDecimal operand2);
Multiplies an arbitrary-precision decimal floating-point number by another arbitrary-precision decimal floating-point number and returns the result.
Parameters:
-
operand1: The first operand.
-
operand2: The second operand.
Return Value:
The product of the two numbers, that is, an arbitrary-precision decimal floating-point number times another arbitrary-precision decimal floating-point number.
Exceptions:
- System.ArgumentNullException: The parameter operand1 or operand2 is null.
public static PeterO.Numbers.EDecimal operator -( PeterO.Numbers.EDecimal bthis, PeterO.Numbers.EDecimal subtrahend);
Subtracts one arbitrary-precision decimal number from another and returns the result.
Parameters:
-
bthis: The first operand.
-
subtrahend: The second operand.
Return Value:
The difference of the two decimal numbers.
Exceptions:
- System.ArgumentNullException: The parameter bthis or subtrahend is null.
public static PeterO.Numbers.EDecimal operator -( PeterO.Numbers.EDecimal bigValue);
Gets an arbitrary-precision decimal number with the same value as the specified one, but with the sign reversed.
Parameters:
- bigValue: An arbitrary-precision decimal number to negate.
Return Value:
An arbitrary-precision decimal number. If this value is positive zero, returns negative zero. Returns signaling NaN if this value is signaling NaN.
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public static PeterO.Numbers.EDecimal PI( PeterO.Numbers.EContext ctx);
Finds the constant π, the circumference of a circle divided by its diameter.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as π can never be represented exactly..
Return Value:
The constant π rounded to the specified precision. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
public PeterO.Numbers.EDecimal Plus( PeterO.Numbers.EContext ctx);
Rounds this object’s value to the specified precision, using the specified rounding mode and range of exponent, and also converts negative zero to positive zero. The idiom EDecimal.SignalingNaN.Plus(ctx)
is useful for triggering an invalid operation and returning not-a-number (NaN) for custom arithmetic operations.
Parameters:
- ctx: A context for controlling the precision, rounding mode, and exponent range. Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
The closest value to this object’s value, rounded to the specified precision. If ctx is null or the precision and exponent range are unlimited, returns the same value as this object (or a quiet NaN if this object is a signaling NaN).
public PeterO.Numbers.EDecimal Pow( int exponentSmall, PeterO.Numbers.EContext ctx);
Raises this object’s value to the specified exponent.
Parameters:
-
exponentSmall: The exponent to raise this object’s value to.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
This^exponent. Signals the flag FlagInvalid and returns NaN if this object and exponent are both 0.
public PeterO.Numbers.EDecimal Pow( int exponentSmall);
Raises this object’s value to the specified exponent.
Parameters:
- exponentSmall: The exponent to raise this object’s value to.
Return Value:
This^exponent. Returns not-a-number (NaN) if this object and exponent are both 0.
public PeterO.Numbers.EDecimal Pow( PeterO.Numbers.EDecimal exponent, PeterO.Numbers.EContext ctx);
Raises this object’s value to the specified exponent.
Parameters:
-
exponent: An arbitrary-precision decimal number expressing the exponent to raise this object’s value to.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
This^exponent. Signals the flag FlagInvalid and returns NaN if this object and exponent are both 0; or if this value is less than 0 and the exponent either has a fractional part or is infinity. Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0), and the exponent has a fractional part.
public PeterO.Numbers.EDecimal Pow( PeterO.Numbers.EDecimal exponent);
Raises this object’s value to the specified exponent, using unlimited precision.
Parameters:
- exponent: An arbitrary-precision decimal number expressing the exponent to raise this object’s value to.
Return Value:
This^exponent. Returns not-a-number (NaN) if the exponent has a fractional part.
public PeterO.Numbers.EInteger Precision();
Finds the number of digits in this number’s significand. Returns 1 if this value is 0, and 0 if this value is infinity or not-a-number (NaN).
Return Value:
An arbitrary-precision integer.
public PeterO.Numbers.EDecimal PreRound( PeterO.Numbers.EContext ctx);
Returns a number in which the value of this object is rounded to fit the maximum precision allowed if it has more significant digits than the maximum precision. The maximum precision allowed is given in an arithmetic context. This method is designed for preparing operands to a custom arithmetic operation per the “simplified” arithmetic given in Appendix A of the General Decimal Arithmetic Specification.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited. Signals the flag LostDigits if the input number has greater precision than allowed and was rounded to a different numerical value in order to fit the precision.
Return Value:
This object rounded to the specified precision. Returns this object and signals no flags if ctx is null or specifies an unlimited precision, if this object is infinity or not-a-number (including signaling NaN), or if the number’s value has no more significant digits than the maximum precision given in ctx .
public PeterO.Numbers.EDecimal Quantize( int desiredExponentInt, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value but a new exponent. Note that this is not always the same as rounding to a given number of decimal places, since it can fail if the difference between this value’s exponent and the desired exponent is too big, depending on the maximum precision. If rounding to a number of decimal places is desired, it’s better to use the RoundToExponent and RoundToIntegral methods instead.
Remark: This method can be used to implement fixed-point decimal arithmetic, in which each decimal number has a fixed number of digits after the decimal point. The following code example returns a fixed-point number with up to 20 digits before and exactly 5 digits after the decimal point:
/* After performing arithmetic operations, adjust the number to 5 digits after the decimal point */ number = number.Quantize(-5, /* five digits after the decimal point */EContext.ForPrecision(25) /* 25-digit precision*/);
A fixed-point decimal arithmetic in which no digits come after the decimal point (a desired exponent of 0) is considered an “integer arithmetic”.
Parameters:
-
desiredExponentInt: The desired exponent for the result. The exponent is the number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
ctx: An arithmetic context to control precision and rounding of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number with the same value as this object but with the exponent changed. Signals FlagInvalid and returns not-a-number (NaN) if this object is infinity, if the rounded result can’t fit the specified precision, or if the context defines an exponent range and the specified exponent is outside that range.
public PeterO.Numbers.EDecimal Quantize( int desiredExponentInt, PeterO.Numbers.ERounding rounding);
Returns an arbitrary-precision decimal number with the same value as this one but a new exponent. Remark: This method can be used to implement fixed-point decimal arithmetic, in which a fixed number of digits come after the decimal point. A fixed-point decimal arithmetic in which no digits come after the decimal point (a desired exponent of 0) is considered an “integer arithmetic” .
Parameters:
-
desiredExponentInt: The desired exponent for the result. The exponent is the number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
rounding: A rounding mode to use in case the result needs to be rounded to fit the specified exponent.
Return Value:
An arbitrary-precision decimal number with the same value as this object but with the exponent changed. Returns not-a-number (NaN) if this object is infinity, or if the rounding mode is ERounding.None and the result is not exact.
public PeterO.Numbers.EDecimal Quantize( PeterO.Numbers.EDecimal otherValue, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but with the same exponent as another decimal number. Note that this is not always the same as rounding to a given number of decimal places, since it can fail if the difference between this value’s exponent and the desired exponent is too big, depending on the maximum precision. If rounding to a number of decimal places is desired, it’s better to use the RoundToExponent and RoundToIntegral methods instead.
Remark: This method can be used to implement fixed-point decimal arithmetic, in which a fixed number of digits come after the decimal point. A fixed-point decimal arithmetic in which no digits come after the decimal point (a desired exponent of 0) is considered an “integer arithmetic” .
Parameters:
-
otherValue: An arbitrary-precision decimal number containing the desired exponent of the result. The significand is ignored. The exponent is the number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousands-place (10^3, 1000). A value of 0 rounds the number to an integer. The following examples for this parameter express a desired exponent of 3:
10e3
,8888e3
,4.56e5
. -
ctx: An arithmetic context to control precision and rounding of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number with the same value as this object but with the exponent changed. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the specified precision without rounding, or if the arithmetic context defines an exponent range and the specified exponent is outside that range.
public PeterO.Numbers.EDecimal Quantize( PeterO.Numbers.EInteger desiredExponent, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value but a new exponent. Note that this is not always the same as rounding to a given number of decimal places, since it can fail if the difference between this value’s exponent and the desired exponent is too big, depending on the maximum precision. If rounding to a number of decimal places is desired, it’s better to use the RoundToExponent and RoundToIntegral methods instead.
Remark: This method can be used to implement fixed-point decimal arithmetic, in which each decimal number has a fixed number of digits after the decimal point. The following code example returns a fixed-point number with up to 20 digits before and exactly 5 digits after the decimal point:
/* After performing arithmetic operations, adjust /* the number to 5*/*/ /**/ digits after the decimal point number = number.Quantize( EInteger.FromInt32(-5), /* five digits after the decimal point*/ EContext.ForPrecision(25) /* 25-digit precision);*/
A fixed-point decimal arithmetic in which no digits come after the decimal point (a desired exponent of 0) is considered an “integer arithmetic”.
Parameters:
-
desiredExponent: The desired exponent for the result. The exponent is the number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
ctx: An arithmetic context to control precision and rounding of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number with the same value as this object but with the exponent changed. Signals FlagInvalid and returns not-a-number (NaN) if this object is infinity, if the rounded result can’t fit the specified precision, or if the context defines an exponent range and the specified exponent is outside that range.
public PeterO.Numbers.EDecimal Reduce( PeterO.Numbers.EContext ctx);
Returns an object with the same numerical value as this one but with trailing zeros removed from its significand. For example, 1.00 becomes 1. If this object’s value is 0, changes the exponent to 0.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and rounding isn’t needed.
Return Value:
This value with trailing zeros removed. Note that if the result has a very high exponent and the context says to clamp high exponents, there may still be some trailing zeros in the significand.
public PeterO.Numbers.EDecimal Remainder( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Returns the remainder that would result when this arbitrary-precision decimal floating-point number is divided by another arbitrary-precision decimal floating-point number. The remainder is the number that remains when the absolute value of this arbitrary-precision decimal floating-point number is divided (as though by DivideToIntegerZeroScale) by the absolute value of the other arbitrary-precision decimal floating-point number; the remainder has the same sign (positive or negative) as this arbitrary-precision decimal floating-point number.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result, and of the intermediate integer division. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which the precision is unlimited.
Return Value:
The remainder that would result when this arbitrary-precision decimal floating-point number is divided by another arbitrary-precision decimal floating-point number. Signals FlagDivideByZero and returns infinity if the divisor (this arbitrary-precision decimal floating-point number) is 0 and the dividend (the other arbitrary-precision decimal floating-point number) is nonzero. Signals FlagInvalid and returns not-a-number (NaN) if the divisor and the dividend are 0, or if the result of the division doesn’t fit the specified precision.
public PeterO.Numbers.EDecimal RemainderNaturalScale( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Calculates the remainder of a number by the formula “this” - ((“this” / “divisor”) * “divisor”).
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only in the division portion of the remainder calculation; as a result, it’s possible for the return value to have a higher precision than given in this context. Flags will be set on the specified context only if the context’s
HasFlags
is true and the integer part of the division result doesn’t fit the precision and exponent range without rounding. Can be null, in which the precision is unlimited and no additional rounding, other than the rounding down to an integer after division, is needed.
Return Value:
An arbitrary-precision decimal number.
public PeterO.Numbers.EDecimal RemainderNaturalScale( PeterO.Numbers.EDecimal divisor);
Calculates the remainder of a number by the formula "this" - (("this" / "divisor") * "divisor")
.
Parameters:
- divisor: The number to divide by.
Return Value:
An arbitrary-precision decimal number.
public PeterO.Numbers.EDecimal RemainderNear( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Finds the distance to the closest multiple of the specified divisor, based on the result of dividing this object’s value by another object’s value.
-
If this and the other object divide evenly, the result is 0.
-
If the remainder’s absolute value is less than half of the divisor’s absolute value, the result has the same sign as this object and will be the distance to the closest multiple.
-
If the remainder’s absolute value is more than half of the divisor’s absolute value, the result has the opposite sign of this object and will be the distance to the closest multiple.
-
If the remainder’s absolute value is exactly half of the divisor’s absolute value, the result has the opposite sign of this object if the quotient, rounded down, is odd, and has the same sign as this object if the quotient, rounded down, is even, and the result’s absolute value is half of the divisor’s absolute value.
This function is also known as the “IEEE Remainder” function.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision. The rounding and exponent range settings of this context are ignored (the rounding mode is always treated as HalfEven). If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which the precision is unlimited.
Return Value:
The distance of the closest multiple. Signals FlagInvalid and returns not-a-number (NaN) if the divisor is 0, or either the result of integer division (the quotient) or the remainder wouldn’t fit the specified precision.
### RemainderNoRoundAfterDivide
public PeterO.Numbers.EDecimal RemainderNoRoundAfterDivide( PeterO.Numbers.EDecimal divisor, PeterO.Numbers.EContext ctx);
Finds the remainder that results when dividing two arbitrary-precision decimal numbers, except the intermediate division is not adjusted to fit the precision of the specified arithmetic context. The value of this object is divided by the absolute value of the other object; the remainder has the same sign (positive or negative) as this object’s value.
Parameters:
-
divisor: The number to divide by.
-
ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result, but not also of the intermediate integer division. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which the precision is unlimited.
Return Value:
The remainder of the two numbers. Signals FlagInvalid and returns not-a-number (NaN) if the divisor is 0, or if the result doesn’t fit the specified precision.
public PeterO.Numbers.EDecimal RoundToExponent( int exponentSmall, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponentSmall: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable in the specified precision. If the result can’t fit the precision, additional digits are discarded to make it fit. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to the specified exponent when rounding, and the specified exponent is outside the valid range of the arithmetic context.
public PeterO.Numbers.EDecimal RoundToExponent( int exponentSmall, PeterO.Numbers.ERounding rounding);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponentSmall: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
rounding: The desired mode to use to round the specified number to the specified exponent.
Return Value:
An arbitrary-precision decimal number rounded to the specified negative number of decimal places.
public PeterO.Numbers.EDecimal RoundToExponent( int exponentSmall);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary, using the HalfEven rounding mode. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
- exponentSmall: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable for the specified exponent.
public PeterO.Numbers.EDecimal RoundToExponent( PeterO.Numbers.EInteger exponent, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponent: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable in the specified precision. If the result can’t fit the precision, additional digits are discarded to make it fit. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to the specified exponent when rounding, and the specified exponent is outside the valid range of the arithmetic context.
public PeterO.Numbers.EDecimal RoundToExponent( PeterO.Numbers.EInteger exponent, PeterO.Numbers.ERounding rounding);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary, using the specified rounding mode. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponent: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
rounding: Desired mode for rounding this number’s value.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable for the specified exponent.
public PeterO.Numbers.EDecimal RoundToExponent( PeterO.Numbers.EInteger exponent);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to a new exponent if necessary, using the HalfEven rounding mode. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
- exponent: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable for the specified exponent.
public PeterO.Numbers.EDecimal RoundToExponentExact( int exponentSmall, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to the specified exponent represented as a 32-bit signed integer, and signals an inexact flag if the result would be inexact. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponentSmall: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable in the specified precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the specified precision without rounding. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to the specified exponent when rounding, and the specified exponent is outside the valid range of the arithmetic context.
public PeterO.Numbers.EDecimal RoundToExponentExact( int exponentSmall, PeterO.Numbers.ERounding rounding);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to the specified exponent represented as a 32-bit signed integer, and signals an inexact flag if the result would be inexact. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponentSmall: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
rounding: Desired mode for rounding this object’s value.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable using the specified exponent.
public PeterO.Numbers.EDecimal RoundToExponentExact( PeterO.Numbers.EInteger exponent, PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to the specified exponent represented as an arbitrary-precision integer, and signals an inexact flag if the result would be inexact. The resulting number’s Exponent property will not necessarily be the specified exponent; use the Quantize method instead to give the result a particular exponent.
Parameters:
-
exponent: The minimum exponent the result can have. This is the maximum number of fractional digits in the result, expressed as a negative number. Can also be positive, which eliminates lower-order places from the number. For example, -3 means round to the thousandth (10^-3, 0.0001), and 3 means round to the thousand (10^3, 1000). A value of 0 rounds the number to an integer.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest value representable in the specified precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the specified precision without rounding. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to the specified exponent when rounding, and the specified exponent is outside the valid range of the arithmetic context.
public PeterO.Numbers.EDecimal RoundToIntegerExact( PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to an integer, and signals an inexact flag if the result would be inexact. The resulting number’s Exponent property will not necessarily be 0; use the Quantize method instead to give the result an exponent of 0.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest integer representable in the specified precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the specified precision without rounding. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to 0 when rounding, and 0 is outside the valid range of the arithmetic context.
### RoundToIntegerNoRoundedFlag
public PeterO.Numbers.EDecimal RoundToIntegerNoRoundedFlag( PeterO.Numbers.EContext ctx);
Returns an arbitrary-precision decimal number with the same value as this object but rounded to an integer, without adding the FlagInexact
or FlagRounded
flags. The resulting number’s Exponent property will not necessarily be 0; use the Quantize method instead to give the result an exponent of 0.
Parameters:
- ctx: An arithmetic context to control precision and rounding of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags), except that this function will never add theFlagRounded
andFlagInexact
flags (the only difference between this and RoundToExponentExact). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest integer representable in the specified precision. If the result can’t fit the precision, additional digits are discarded to make it fit. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to 0 when rounding, and 0 is outside the valid range of the arithmetic context.
public PeterO.Numbers.EDecimal RoundToIntegralExact( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to RoundToIntegerExact.
Returns an arbitrary-precision decimal number with the same value as this object but rounded to an integer, and signals an inexact flag if the result would be inexact.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest integer representable in the specified precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the specified precision without rounding. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to 0 when rounding, and 0 is outside the valid range of the arithmetic context.
### RoundToIntegralNoRoundedFlag
public PeterO.Numbers.EDecimal RoundToIntegralNoRoundedFlag( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to RoundToIntegerNoRoundedFlag.
Returns an arbitrary-precision decimal number with the same value as this object but rounded to an integer, without adding the FlagInexact
or FlagRounded
flags.
Parameters:
- ctx: An arithmetic context to control precision and rounding of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags), except that this function will never add theFlagRounded
andFlagInexact
flags (the only difference between this and RoundToExponentExact). Can be null, in which case the default rounding mode is HalfEven.
Return Value:
An arbitrary-precision decimal number rounded to the closest integer representable in the specified precision. If the result can’t fit the precision, additional digits are discarded to make it fit. Signals FlagInvalid and returns not-a-number (NaN) if the arithmetic context defines an exponent range, the new exponent must be changed to 0 when rounding, and 0 is outside the valid range of the arithmetic context.
public PeterO.Numbers.EDecimal RoundToPrecision( PeterO.Numbers.EContext ctx);
Rounds this object’s value to the specified precision, using the specified rounding mode and range of exponent.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The closest value to this object’s value, rounded to the specified precision. Returns the same value as this object if ctx is null or the precision and exponent range are unlimited.
public PeterO.Numbers.EDecimal ScaleByPowerOfTen( int places, PeterO.Numbers.EContext ctx);
Returns a number similar to this number but with the scale adjusted.
Parameters:
-
places: The power of 10 to scale by.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
A number whose exponent is generally increased by places . For example, in general, if places is 5, “78E-2” becomes “78E+3” and has a bigger value.
public PeterO.Numbers.EDecimal ScaleByPowerOfTen( int places);
Returns a number similar to this number but with the scale adjusted.
Parameters:
- places: The power of 10 to scale by.
Return Value:
A number whose exponent is increased by places . For example, if places is 5, “78E-2” becomes “78E+3” and has a bigger value.
public PeterO.Numbers.EDecimal ScaleByPowerOfTen( PeterO.Numbers.EInteger bigPlaces, PeterO.Numbers.EContext ctx);
Returns a number similar to this number but with its scale adjusted.
Parameters:
-
bigPlaces: The power of 10 to scale by.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
A number whose exponent is generally increased by bigPlaces . For example, in general, if bigPlaces is 5, “78E-2” becomes “78E+3” and has a bigger value.
Exceptions:
- System.ArgumentNullException: The parameter bigPlaces is null.
public PeterO.Numbers.EDecimal ScaleByPowerOfTen( PeterO.Numbers.EInteger bigPlaces);
Returns a number similar to this number but with the scale adjusted.
Parameters:
- bigPlaces: The power of 10 to scale by.
Return Value:
A number whose exponent is increased by bigPlaces . For example, if bigPlaces is 5, “78E-2” becomes “78E+3” and has a bigger value.
public PeterO.Numbers.EDecimal Sqrt( PeterO.Numbers.EContext ctx);
Finds the square root of this object’s value.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the square root function’s results are generally not exact for many inputs. (Unlike in the General Decimal Arithmetic Specification, any rounding mode is allowed.).
Return Value:
The square root. Signals the flag FlagInvalid and returns NaN if this object is less than 0 (the square root would be a complex number, but the return value is still NaN). Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
public PeterO.Numbers.EDecimal SquareRoot( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to Sqrt.
Finds the square root of this object’s value.
Parameters:
- ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). This parameter can’t be null, as the square root function’s results are generally not exact for many inputs. (Unlike in the General Decimal Arithmetic Specification, any rounding mode is allowed.).
Return Value:
The square root. Signals the flag FlagInvalid and returns NaN if this object is less than 0 (the square root would be a complex number, but the return value is still NaN). Signals FlagInvalid and returns not-a-number (NaN) if the parameter ctx is null or the precision is unlimited (the context’s Precision property is 0).
public PeterO.Numbers.EDecimal Subtract( int intValue);
Subtracts a 32-bit signed integer from this arbitrary-precision decimal floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision decimal floating-point number’s exponent and the other 32-bit signed integer’s exponent.
Parameters:
- intValue: A 32-bit signed integer to subtract from this object.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision decimal floating-point number minus a 32-bit signed integer. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public PeterO.Numbers.EDecimal Subtract( long longValue);
Subtracts a 64-bit signed integer from this arbitrary-precision decimal floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision decimal floating-point number’s exponent and the other 64-bit signed integer’s exponent.
Parameters:
- longValue: The parameter longValue is a 64-bit signed integer.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision decimal floating-point number minus a 64-bit signed integer. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public PeterO.Numbers.EDecimal Subtract( PeterO.Numbers.EDecimal otherValue, PeterO.Numbers.EContext ctx);
Subtracts an arbitrary-precision decimal floating-point number from this arbitrary-precision decimal floating-point number and returns the result.
Parameters:
-
otherValue: The number to subtract from this instance’s value.
-
ctx: An arithmetic context to control the precision, rounding, and exponent range of the result. If
HasFlags
of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision decimal floating-point number minus another arbitrary-precision decimal floating-point number. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public PeterO.Numbers.EDecimal Subtract( PeterO.Numbers.EDecimal otherValue);
Subtracts an arbitrary-precision decimal floating-point number from this arbitrary-precision decimal floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision decimal floating-point number’s exponent and the other arbitrary-precision decimal floating-point number’s exponent.
Parameters:
- otherValue: The number to subtract from this instance’s value.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision decimal floating-point number minus another arbitrary-precision decimal floating-point number. If this arbitrary-precision decimal floating-point number is not-a-number (NaN), returns NaN.
public byte ToByteChecked();
Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a byte (from 0 to 255).
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 255.
public byte ToByteIfExact();
Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.
Return Value:
This number’s value as a byte (from 0 to 255).
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 255.
public byte ToByteUnchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a byte (from 0 to 255).
Return Value:
This number, converted to a byte (from 0 to 255). Returns 0 if this value is infinity or not-a-number.
public decimal ToDecimal();
Converts this value to a decimal
under the Common Language Infrastructure (see "Forms of numbers"“Forms of numbers” ), using the half-even rounding mode.
Return Value:
A decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
public double ToDouble();
Converts this value to its closest equivalent as a 64-bit floating-point number, using the half-even rounding mode. If this value is a NaN, sets the high bit of the 64-bit floating point number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN. Unfortunately, in the.NET implementation, the return value of this method may be a quiet NaN even if a signaling NaN would otherwise be generated.
Return Value:
The closest 64-bit floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 64-bit floating point number.
public long ToDoubleBits();
Converts this value to its closest equivalent as a 64-bit floating-point number encoded in the IEEE 754 binary64 format, using the half-even rounding mode. If this value is a NaN, sets the high bit of the binary64 value’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN.
Return Value:
The closest 64-bit floating-point number to this value, encoded in the IEEE 754 binary64 format. The return value can be positive infinity or negative infinity, encoded in the IEEE 754 binary64 format, if this value exceeds the range of a 64-bit floating point number.
public PeterO.Numbers.EFloat ToEFloat( PeterO.Numbers.EContext ec);
Creates a binary floating-point number from this object’s value. Note that if the binary floating-point number contains a negative exponent, the resulting value might not be exact, in which case the resulting binary floating-point number will be an approximation of this decimal number’s value.
Parameters:
- ec: An arithmetic context to control the precision, rounding, and exponent range of the result. The precision is in bits, and an example of this parameter is
EContext.Binary64
. Can be null.
Return Value:
An arbitrary-precision floating-point number.
public PeterO.Numbers.EFloat ToEFloat();
Creates a binary floating-point number from this object’s value. Note that if the binary floating-point number contains a negative exponent, the resulting value might not be exact, in which case the resulting binary floating-point number will be an approximation of this decimal number’s value, using the half-even rounding mode.
Return Value:
An arbitrary-precision binary floating-point number.
public PeterO.Numbers.EInteger ToEInteger();
Converts this value to an arbitrary-precision integer, discarding the fractional part in this value. Note that depending on the value, especially the exponent, generating the arbitrary-precision integer may require a huge amount of memory. Use the ToSizedEInteger method to convert a number to an EInteger only if the integer fits in a bounded bit range; that method will throw an exception on overflow.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN).
-
System.NotSupportedException: There is not enough memory to store the value as an EInteger.
public PeterO.Numbers.EInteger ToEIntegerExact();
Obsolete. Renamed to ToEIntegerIfExact.
Converts this value to an arbitrary-precision integer, checking whether the fractional part of the value would be lost. Note that depending on the value, especially the exponent, generating the arbitrary-precision integer may require a huge amount of memory. Use the ToSizedEIntegerIfExact method to convert a number to an EInteger only if the integer fits in a bounded bit range; that method will throw an exception on overflow.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN).
-
System.ArithmeticException: This object’s value is not an exact integer.
public PeterO.Numbers.EInteger ToEIntegerIfExact();
Converts this value to an arbitrary-precision integer, checking whether the fractional part of the value would be lost. Note that depending on the value, especially the exponent, generating the arbitrary-precision integer may require a huge amount of memory. Use the ToSizedEIntegerIfExact method to convert a number to an EInteger only if the integer fits in a bounded bit range; that method will throw an exception on overflow.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN).
-
System.ArithmeticException: This object’s value is not an exact integer.
public string ToEngineeringString();
Same as ToString(), except that when an exponent is used it will be a multiple of 3.
Return Value:
A text string.
public PeterO.Numbers.EFloat ToExtendedFloat();
Obsolete. Renamed to ToEFloat.
Creates a binary floating-point number from this object’s value. Note that if the binary floating-point number contains a negative exponent, the resulting value might not be exact, in which case the resulting binary floating-point number will be an approximation of this decimal number’s value, using the half-even rounding mode.
Return Value:
An arbitrary-precision binary floating-point number.
public short ToHalfBits();
Converts this value to its closest equivalent as a binary floating-point number, expressed as an integer in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number). The half-even rounding mode is used. If this value is a NaN, sets the high bit of the binary16 number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN.
Return Value:
The closest binary floating-point number to this value, expressed as an integer in the IEEE 754 binary16 format. The return value can be positive infinity or negative infinity if this value exceeds the range of a floating-point number in the binary16 format.
public short ToInt16Checked();
Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 16-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -32768 or greater than 32767.
public short ToInt16IfExact();
Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 16-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -32768 or greater than 32767.
public short ToInt16Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit signed integer.
Return Value:
This number, converted to a 16-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public int ToInt32Checked();
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 32-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -2147483648 or greater than 2147483647.
public int ToInt32IfExact();
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -2147483648 or greater than 2147483647.
public int ToInt32Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.
Return Value:
This number, converted to a 32-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public long ToInt64Checked();
Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 64-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -9223372036854775808 or greater than 9223372036854775807.
public long ToInt64IfExact();
Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 64-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -9223372036854775808 or greater than 9223372036854775807.
public long ToInt64Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit signed integer.
Return Value:
This number, converted to a 64-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public string ToPlainString();
Converts this value to a string as though with the ToString method, but without using exponential notation.
Return Value:
A text string.
public sbyte ToSByteChecked();
This API is not CLS-compliant.
Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to an 8-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -128 or greater than 127.
public sbyte ToSByteIfExact();
This API is not CLS-compliant.
Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as an 8-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -128 or greater than 127.
public sbyte ToSByteUnchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as an 8-bit signed integer.
Return Value:
This number, converted to an 8-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public float ToSingle();
Converts this value to its closest equivalent as a 32-bit floating-point number, using the half-even rounding mode. If this value is a NaN, sets the high bit of the 32-bit floating point number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN. Unfortunately, in the.NET implementation, the return value of this method may be a quiet NaN even if a signaling NaN would otherwise be generated.
Return Value:
The closest 32-bit binary floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 32-bit floating point number.
public int ToSingleBits();
Converts this value to its closest equivalent as a 32-bit floating-point number encoded in the IEEE 754 binary32 format, using the half-even rounding mode. If this value is a NaN, sets the high bit of the 32-bit floating point number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN.
Return Value:
The closest 32-bit binary floating-point number to this value, encoded in the IEEE 754 binary32 format. The return value can be positive infinity or negative infinity if this value exceeds the range of a 32-bit floating point number.
public PeterO.Numbers.EInteger ToSizedEInteger( int maxBitLength);
Converts this value to an arbitrary-precision integer by discarding its fractional part and checking whether the resulting integer overflows the specified signed bit count.
Parameters:
- maxBitLength: The maximum number of signed bits the integer can have. The integer’s value may not be less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
Return Value:
An arbitrary-precision integer.
Exceptions:
- System.OverflowException: This object’s value is infinity or not-a-number (NaN), or this number’s value, once converted to an integer by discarding its fractional part, is less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
public PeterO.Numbers.EInteger ToSizedEIntegerIfExact( int maxBitLength);
Converts this value to an arbitrary-precision integer, only if this number’s value is an exact integer and that integer does not overflow the specified signed bit count.
Parameters:
- maxBitLength: The maximum number of signed bits the integer can have. The integer’s value may not be less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN), or this number’s value, once converted to an integer by discarding its fractional part, is less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
-
System.ArithmeticException: This object’s value is not an exact integer.
public override string ToString();
Converts this value to a text string. Returns a value compatible with this class’s FromString method.
Return Value:
A string representation of this object. The text string will be in exponential notation (expressed as a number 1 or greater, but less than 10, times a power of 10) if this object’s Exponent property is greater than 0 or if the number’s first nonzero decimal digit is more than five digits after the decimal point.
public ushort ToUInt16Checked();
This API is not CLS-compliant.
Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 16-bit unsigned integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 65535.
public ushort ToUInt16IfExact();
This API is not CLS-compliant.
Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer without rounding to a different numerical value.
Return Value:
This number’s value as a 16-bit unsigned integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 65535.
public ushort ToUInt16Unchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit unsigned integer.
Return Value:
This number, converted to a 16-bit unsigned integer. Returns 0 if this value is infinity or not-a-number.
public uint ToUInt32Checked();
This API is not CLS-compliant.
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 32-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 4294967295.
public uint ToUInt32IfExact();
This API is not CLS-compliant.
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 4294967295.
public uint ToUInt32Unchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.
Return Value:
This number, converted to a 32-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public ulong ToUInt64Checked();
This API is not CLS-compliant.
Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 64-bit unsigned integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 18446744073709551615.
public ulong ToUInt64IfExact();
This API is not CLS-compliant.
Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer without rounding to a different numerical value.
Return Value:
This number’s value as a 64-bit unsigned integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 18446744073709551615.
public ulong ToUInt64Unchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit unsigned integer.
Return Value:
This number, converted to a 64-bit unsigned integer. Returns 0 if this value is infinity or not-a-number.
public PeterO.Numbers.EDecimal Ulp();
Returns the unit in the last place. The significand will be 1 and the exponent will be this number’s exponent. Returns 1 with an exponent of 0 if this number is infinity or not-a-number (NaN).
Return Value:
An arbitrary-precision decimal number.