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 non-zero 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:

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:

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:

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:

Signed integer : An integer in two’s-complement form , with the following ranges:

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|

The elements described above 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:

.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:

The elements described above 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

### NaN

public static readonly PeterO.Numbers.EDecimal NaN;

A not-a-number value.

### NegativeInfinity

public static readonly PeterO.Numbers.EDecimal NegativeInfinity;

Negative infinity, less than any other number.

### NegativeZero

public static readonly PeterO.Numbers.EDecimal NegativeZero;

Represents the number negative zero.

### One

public static readonly PeterO.Numbers.EDecimal One;

Represents the number 1.

### PositiveInfinity

public static readonly PeterO.Numbers.EDecimal PositiveInfinity;

Positive infinity, greater than any other number.

### SignalingNaN

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.

### Ten

public static readonly PeterO.Numbers.EDecimal Ten;

Represents the number 10.

### Zero

public static readonly PeterO.Numbers.EDecimal Zero;

Represents the number 0.

### Exponent

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.

### IsFinite

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 .

### IsNegative

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 .

### IsZero

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 .

### Mantissa

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).

### Sign

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.

### UnsignedMantissa

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.

### Abs

public PeterO.Numbers.EDecimal Abs(
    PeterO.Numbers.EContext context);

Finds the absolute value of this object (if it’s negative, it becomes positive).

Parameters:

Return Value:

The absolute value of this object. Signals FlagInvalid and returns quiet NaN if this value is signaling NaN.

### Abs

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.).

### Add

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:

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.

### Add

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:

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.

### Add

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:

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.

### Add

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:

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.

### CompareTo

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:

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.

### CompareTo

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:

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.

### CompareTo

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:

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.

.

### CompareToBinary

public int CompareToBinary(
    PeterO.Numbers.EFloat other);

Compares an arbitrary-precision binary floating-point number with this instance.

Parameters:

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.

.

### CompareToSignal

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:

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.

.

### CompareToTotal

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:

Parameters:

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.

.

### CompareToTotal

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:

Parameters:

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.

.

### CompareToTotalMagnitude

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:

Parameters:

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.

.

### CompareToTotalMagnitude

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:

Parameters:

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.

.

### CompareToValue

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:

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.

### CompareToValue

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:

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.

### CompareToValue

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:

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.

.

### CompareToWithContext

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:

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.

.

### Copy

public PeterO.Numbers.EDecimal Copy();

Creates a copy of this arbitrary-precision binary number.

Return Value:

An arbitrary-precision decimal floating-point number.

### CopySign

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:

Return Value:

An arbitrary-precision decimal number.

Exceptions:

### Create

public static PeterO.Numbers.EDecimal Create(
    int mantissaSmall,
    int exponentSmall);

Returns a number with the value exponent*10^significand .

Parameters:

Return Value:

An arbitrary-precision decimal number.

### Create

public static PeterO.Numbers.EDecimal Create(
    long mantissaLong,
    int exponentSmall);

Creates a number with the value exponent*10^significand .

Parameters:

Return Value:

An arbitrary-precision decimal number.

### Create

public static PeterO.Numbers.EDecimal Create(
    long mantissaLong,
    long exponentLong);

Creates a number with the value exponent*10^significand .

Parameters:

Return Value:

An arbitrary-precision decimal number.

### Create

public static PeterO.Numbers.EDecimal Create(
    PeterO.Numbers.EInteger mantissa,
    int exponentSmall);

Creates a number with the value exponent*10^significand .

Parameters:

Return Value:

An arbitrary-precision decimal number.

Exceptions:

### Create

public static PeterO.Numbers.EDecimal Create(
    PeterO.Numbers.EInteger mantissa,
    long exponentLong);

Creates a number with the value exponent*10^significand .

Parameters:

Return Value:

An arbitrary-precision decimal number.

Exceptions:

### Create

public static PeterO.Numbers.EDecimal Create(
    PeterO.Numbers.EInteger mantissa,
    PeterO.Numbers.EInteger exponent);

Creates a number with the value exponent*10^significand .

Parameters:

Return Value:

An arbitrary-precision decimal number.

Exceptions:

### CreateNaN

public static PeterO.Numbers.EDecimal CreateNaN(
    PeterO.Numbers.EInteger diag);

Creates a not-a-number arbitrary-precision decimal number.

Parameters:

Return Value:

A quiet not-a-number.

### CreateNaN

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:

Return Value:

An arbitrary-precision decimal number.

Exceptions:

### Decrement

public PeterO.Numbers.EDecimal Decrement();

Returns one subtracted from this arbitrary-precision decimal number.

Return Value:

The given arbitrary-precision decimal number minus one.

### Divide

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, 2/3, and so on); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.

Parameters:

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.

### Divide

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, 2/3, and so on); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.

Parameters:

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.

### Divide

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, 2/3, and so on); if this is not desired, use DivideToExponent, or use the Divide overload that takes an EContext.

Parameters:

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.

### Divide

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:

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.

### DivideAndRemainderNaturalScale

public PeterO.Numbers.EDecimal[] DivideAndRemainderNaturalScale(
    PeterO.Numbers.EDecimal divisor);

Deprecated. Renamed to DivRemNaturalScale.

Calculates the quotient and remainder using the DivideToIntegerNaturalScale and the formula in RemainderNaturalScale.

Parameters:

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,
    PeterO.Numbers.EContext ctx);

Deprecated. Renamed to DivRemNaturalScale.

Calculates the quotient and remainder using the DivideToIntegerNaturalScale and the formula in RemainderNaturalScale.

Parameters:

Return Value:

A 2 element array consisting of the quotient and remainder in that order.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### DivideToExponent

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:

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.

### 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:

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.

### 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:

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.

### DivideToIntegerZeroScale

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:

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 given precision.

### DivideToSameExponent

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:

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.

### DivRemNaturalScale

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:

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.

### DivRemNaturalScale

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:

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.

### Equals

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:

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.

### Equals

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:

Return Value:

true if this object’s significand and exponent are equal to those of another object; otherwise, false .

### Exp

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:

Return Value:

Exponential of this object. If this object’s value is 1, returns an approximation to “ e” within the given 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).

### ExpM1

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:

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).

### FromBoolean

public static PeterO.Numbers.EDecimal FromBoolean(
    bool boolValue);

Converts a boolean value (true or false) to an arbitrary-precision decimal number.

Parameters:

Return Value:

The number 1 if boolValue is true; otherwise, 0.

### FromByte

public static PeterO.Numbers.EDecimal FromByte(
    byte inputByte);

Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision decimal number.

### FromDecimal

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:

Return Value:

An arbitrary-precision decimal floating-point number.

### FromDouble

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:

Return Value:

An arbitrary-precision decimal number with the same value as dbl .

### FromDoubleBits

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:

Return Value:

An arbitrary-precision decimal number with the same value as dblBits .

### FromEFloat

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:

Return Value:

An arbitrary-precision decimal number.

Exceptions:

### FromEInteger

public static PeterO.Numbers.EDecimal FromEInteger(
    PeterO.Numbers.EInteger bigint);

Converts an arbitrary-precision integer to an arbitrary precision decimal.

Parameters:

Return Value:

An arbitrary-precision decimal number with the exponent set to 0.

### FromExtendedFloat

public static PeterO.Numbers.EDecimal FromExtendedFloat(
    PeterO.Numbers.EFloat ef);

Deprecated. Renamed to FromEFloat.

Converts an arbitrary-precision binary floating-point number to an arbitrary precision decimal.

Parameters:

Return Value:

An arbitrary-precision decimal number.

### FromHalfBits

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:

Return Value:

A decimal floating-point number with the same floating-point value as value .

### FromInt16

public static PeterO.Numbers.EDecimal FromInt16(
    short inputInt16);

Converts a 16-bit signed integer to an arbitrary-precision decimal number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision decimal number.

### FromInt32

public static PeterO.Numbers.EDecimal FromInt32(
    int valueSmaller);

Creates an arbitrary-precision decimal number from a 32-bit signed integer.

Parameters:

Return Value:

An arbitrary-precision decimal number with the exponent set to 0.

### FromInt64

public static PeterO.Numbers.EDecimal FromInt64(
    long valueSmall);

Creates an arbitrary-precision decimal number from a 64-bit signed integer.

Parameters:

Return Value:

This number’s value as an arbitrary-precision decimal number with the exponent set to 0.

### FromInt64AsUnsigned

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:

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.

### FromSByte

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:

Return Value:

This number’s value as an arbitrary-precision decimal number.

### FromSingle

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:

Return Value:

An arbitrary-precision decimal number with the same value as flt .

### FromSingleBits

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:

Return Value:

An arbitrary-precision decimal number with the same value as value .

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of bytes (interpreted as text).

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of bytes (interpreted as text).

Exceptions:

### FromString

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:

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 upper-case and/or basic lower-case letters.

All characters mentioned above 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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of bytes (interpreted as text).

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of bytes (interpreted as text).

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of char s.

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of char s.

Exceptions:

### FromString

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:

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 upper-case and/or basic lower-case letters.

All characters mentioned above 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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of char s.

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given sequence of char s.

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given string.

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given string.

Exceptions:

### FromString

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:

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 upper-case and/or basic lower-case letters.

All characters mentioned above 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:

Return Value:

An arbitrary-precision decimal number with the same value as the given string.

Exceptions:

### FromString

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:

Return Value:

An arbitrary-precision decimal number with the same value as the given string.

Exceptions:

### FromUInt16

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:

Return Value:

This number’s value as an arbitrary-precision decimal number.

### FromUInt32

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:

Return Value:

This number’s value as an arbitrary-precision decimal number.

### FromUInt64

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:

Return Value:

This number’s value as an arbitrary-precision decimal number.

### GetHashCode

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.

### Increment

public PeterO.Numbers.EDecimal Increment();

Returns one added to this arbitrary-precision decimal number.

Return Value:

The given arbitrary-precision decimal number plus one.

### IsInfinity

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 .

### IsInteger

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 .

### IsNaN

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 .

### IsNegativeInfinity

public bool IsNegativeInfinity();

Returns whether this object is negative infinity.

Return Value:

true if this object is negative infinity; otherwise, false .

### IsPositiveInfinity

public bool IsPositiveInfinity();

Returns whether this object is positive infinity.

Return Value:

true if this object is positive infinity; otherwise, false .

### IsQuietNaN

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 .

### IsSignalingNaN

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 .

### Log

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:

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.

### Log10

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:

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).

### Log1P

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:

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.

### LogN

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:

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:

### Max

public static PeterO.Numbers.EDecimal Max(
    PeterO.Numbers.EDecimal first,
    PeterO.Numbers.EDecimal second);

Gets the greater value between two decimal numbers.

Parameters:

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:

### Max

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:

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:

### MaxMagnitude

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:

Return Value:

The larger value of the two numbers, ignoring their signs.

Exceptions:

### MaxMagnitude

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:

Return Value:

The larger value of the two numbers, ignoring their signs.

Exceptions:

### Min

public static PeterO.Numbers.EDecimal Min(
    PeterO.Numbers.EDecimal first,
    PeterO.Numbers.EDecimal second);

Gets the lesser value between two decimal numbers.

Parameters:

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:

### Min

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:

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:

### MinMagnitude

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:

Return Value:

The smaller value of the two numbers, ignoring their signs.

Exceptions:

### MinMagnitude

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:

Return Value:

The smaller value of the two numbers, ignoring their signs.

Exceptions:

### MovePointLeft

public PeterO.Numbers.EDecimal MovePointLeft(
    int places);

Returns a number similar to this number but with the decimal point moved to the left.

Parameters:

Return Value:

A number whose exponent is decreased by places , but not to more than 0.

### MovePointLeft

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:

Return Value:

A number whose exponent is decreased by places , but not to more than 0.

### MovePointLeft

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:

Return Value:

A number whose exponent is decreased by bigPlaces , but not to more than 0.

### MovePointLeft

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:

Return Value:

A number whose exponent is decreased by bigPlaces , but not to more than 0.

### MovePointRight

public PeterO.Numbers.EDecimal MovePointRight(
    int places);

Returns a number similar to this number but with the decimal point moved to the right.

Parameters:

Return Value:

A number whose exponent is increased by places , but not to more than 0.

### MovePointRight

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:

Return Value:

A number whose exponent is increased by places , but not to more than 0.

### MovePointRight

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:

Return Value:

A number whose exponent is increased by bigPlaces , but not to more than 0.

### MovePointRight

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:

Return Value:

A number whose exponent is increased by bigPlaces , but not to more than 0.

### Multiply

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:

Return Value:

The product of the two numbers, that is, this arbitrary-precision decimal floating-point number times a 32-bit signed integer.

### Multiply

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:

Return Value:

The product of the two numbers, that is, this arbitrary-precision decimal floating-point number times a 64-bit signed integer.

### Multiply

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:

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.

### Multiply

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:

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:

### MultiplyAndAdd

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:

Return Value:

An arbitrary-precision decimal floating-point number.

### MultiplyAndAdd

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:

Return Value:

The result thisValue * multiplicand + augend.

### MultiplyAndSubtract

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:

Return Value:

The result thisValue * multiplicand - subtrahend.

Exceptions:

### Negate

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:

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.

### Negate

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.).

### NextMinus

public PeterO.Numbers.EDecimal NextMinus(
    PeterO.Numbers.EContext ctx);

Finds the largest value that’s smaller than the given value.

Parameters:

Return Value:

Returns the largest value that’s less than the given 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.

### NextPlus

public PeterO.Numbers.EDecimal NextPlus(
    PeterO.Numbers.EContext ctx);

Finds the smallest value that’s greater than the given value.

Parameters:

Return Value:

Returns the smallest value that’s greater than the given 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.

### NextToward

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:

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.

### Operator +

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:

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:

### Operator --

public static PeterO.Numbers.EDecimal operator --(
    PeterO.Numbers.EDecimal bthis);

Subtracts one from an arbitrary-precision decimal number.

Parameters:

Return Value:

The given arbitrary-precision decimal number minus one.

Exceptions:

### Operator /

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:

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:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a byte (from 0 to 255).

Exceptions:

### Explicit Operator

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:

Return Value:

A decimal under the Common Language Infrastructure (usually a.NET Framework decimal).

Exceptions:

### Explicit Operator

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:

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:

### Explicit Operator

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:

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:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a 32-bit signed integer.

Exceptions:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a 64-bit signed integer.

Exceptions:

### Explicit Operator

public static explicit operator PeterO.Numbers.EDecimal(
    bool boolValue);

Converts a boolean value (true or false) to an arbitrary precision decimal.

Parameters:

Return Value:

The number 1 if boolValue is true; otherwise, 0.

### Explicit Operator

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:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Explicit Operator

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:

Return Value:

The value of input , truncated to an 8-bit signed integer.

Exceptions:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a 16-bit signed integer.

Exceptions:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a 32-bit signed integer.

Exceptions:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a 64-bit unsigned integer.

Exceptions:

### Explicit Operator

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:

Return Value:

The value of input , truncated to a 16-bit unsigned integer.

Exceptions:

### Implicit Operator

public static implicit operator PeterO.Numbers.EDecimal(
    byte inputByte);

Converts a byte (from 0 to 255) to an arbitrary-precision decimal number.

Parameters:

Return Value:

The value of inputByte as an arbitrary-precision decimal number.

### Implicit Operator

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:

Return Value:

A decimal under the Common Language Infrastructure (usually a.NET Framework decimal).

### Implicit Operator

public static implicit operator PeterO.Numbers.EDecimal(
    int inputInt32);

Converts a 32-bit signed integer to an arbitrary-precision decimal number.

Parameters:

Return Value:

The value of inputInt32 as an arbitrary-precision decimal number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EDecimal(
    long inputInt64);

Converts a 64-bit signed integer to an arbitrary-precision decimal number.

Parameters:

Return Value:

The value of inputInt64 as an arbitrary-precision decimal number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EDecimal(
    PeterO.Numbers.EInteger eint);

Converts an arbitrary-precision integer to an arbitrary precision decimal.

Parameters:

Return Value:

An arbitrary-precision decimal number with the exponent set to 0.

### Implicit Operator

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:

Return Value:

The value of inputSByte as an arbitrary-precision decimal number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EDecimal(
    short inputInt16);

Converts a 16-bit signed integer to an arbitrary-precision decimal number.

Parameters:

Return Value:

The value of inputInt16 as an arbitrary-precision decimal number.

### Implicit Operator

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:

Return Value:

The value of inputUInt32 as an arbitrary-precision decimal number.

### Implicit Operator

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:

Return Value:

The value of inputUInt64 as an arbitrary-precision decimal number.

### Implicit Operator

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:

Return Value:

The value of inputUInt16 as an arbitrary-precision decimal number.

### Operator ++

public static PeterO.Numbers.EDecimal operator ++(
    PeterO.Numbers.EDecimal bthis);

Adds one to an arbitrary-precision decimal number.

Parameters:

Return Value:

The given arbitrary-precision decimal number plus one.

Exceptions:

### Operator %

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:

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:

### Operator *

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:

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:

### Operator -

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:

Return Value:

The difference of the two decimal numbers.

Exceptions:

### Operator -

public static PeterO.Numbers.EDecimal operator -(
    PeterO.Numbers.EDecimal bigValue);

Gets an arbitrary-precision decimal number with the same value as the given one, but with the sign reversed.

Parameters:

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:

### PI

public static PeterO.Numbers.EDecimal PI(
    PeterO.Numbers.EContext ctx);

Finds the constant π, the circumference of a circle divided by its diameter.

Parameters:

Return Value:

The constant π rounded to the given 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).

### Plus

public PeterO.Numbers.EDecimal Plus(
    PeterO.Numbers.EContext ctx);

Rounds this object’s value to a given precision, using the given 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:

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).

### Pow

public PeterO.Numbers.EDecimal Pow(
    int exponentSmall);

Raises this object’s value to the given exponent.

Parameters:

Return Value:

This^exponent. Returns not-a-number (NaN) if this object and exponent are both 0.

### Pow

public PeterO.Numbers.EDecimal Pow(
    int exponentSmall,
    PeterO.Numbers.EContext ctx);

Raises this object’s value to the given exponent.

Parameters:

Return Value:

This^exponent. Signals the flag FlagInvalid and returns NaN if this object and exponent are both 0.

### Pow

public PeterO.Numbers.EDecimal Pow(
    PeterO.Numbers.EDecimal exponent);

Raises this object’s value to the given exponent, using unlimited precision.

Parameters:

Return Value:

This^exponent. Returns not-a-number (NaN) if the exponent has a fractional part.

### Pow

public PeterO.Numbers.EDecimal Pow(
    PeterO.Numbers.EDecimal exponent,
    PeterO.Numbers.EContext ctx);

Raises this object’s value to the given exponent.

Parameters:

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.

### Precision

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.

### PreRound

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 in accordance with the “simplified” arithmetic given in Appendix A of the General Decimal Arithmetic Specification.

Parameters:

Return Value:

This object rounded to the given 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 .

### Quantize

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:

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 given precision, or if the context defines an exponent range and the given exponent is outside that range.

### Quantize

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:

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.

### Quantize

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:

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 given precision without rounding, or if the arithmetic context defines an exponent range and the given exponent is outside that range.

### Quantize

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:

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 given precision, or if the context defines an exponent range and the given exponent is outside that range.

### Reduce

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:

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.

### Remainder

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:

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 given precision.

### RemainderNaturalScale

public PeterO.Numbers.EDecimal RemainderNaturalScale(
    PeterO.Numbers.EDecimal divisor);

Calculates the remainder of a number by the formula "this" - (("this" / "divisor") * "divisor") .

Parameters:

Return Value:

An arbitrary-precision decimal number.

### RemainderNaturalScale

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:

Return Value:

An arbitrary-precision decimal number.

### RemainderNear

public PeterO.Numbers.EDecimal RemainderNear(
    PeterO.Numbers.EDecimal divisor,
    PeterO.Numbers.EContext ctx);

Finds the distance to the closest multiple of the given divisor, based on the result of dividing this object’s value by another object’s value.

This function is also known as the “IEEE Remainder” function.

Parameters:

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 given 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 given 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:

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 given precision.

### RoundToExponent

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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable for the given exponent.

### RoundToExponent

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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable in the given 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 given exponent when rounding, and the given exponent is outside of the valid range of the arithmetic context.

### RoundToExponent

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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the given negative number of decimal places.

### RoundToExponent

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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable for the given exponent.

### RoundToExponent

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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable in the given 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 given exponent when rounding, and the given exponent is outside of the valid range of the arithmetic context.

### RoundToExponent

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 given rounding mode. The resulting number’s Exponent property will not necessarily be the given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable for the given exponent.

### RoundToExponentExact

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 given 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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable in the given precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the given 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 given exponent when rounding, and the given exponent is outside of the valid range of the arithmetic context.

### RoundToExponentExact

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 given 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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable using the given exponent.

### RoundToExponentExact

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 given 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 given exponent; use the Quantize method instead to give the result a particular exponent.

Parameters:

Return Value:

An arbitrary-precision decimal number rounded to the closest value representable in the given precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the given 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 given exponent when rounding, and the given exponent is outside of the valid range of the arithmetic context.

### RoundToIntegerExact

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:

Return Value:

An arbitrary-precision decimal number rounded to the closest integer representable in the given precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the given 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 of 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:

Return Value:

An arbitrary-precision decimal number rounded to the closest integer representable in the given 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 of the valid range of the arithmetic context.

### RoundToIntegralExact

public PeterO.Numbers.EDecimal RoundToIntegralExact(
    PeterO.Numbers.EContext ctx);

Deprecated. 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:

Return Value:

An arbitrary-precision decimal number rounded to the closest integer representable in the given precision. Signals FlagInvalid and returns not-a-number (NaN) if the result can’t fit the given 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 of the valid range of the arithmetic context.

### RoundToIntegralNoRoundedFlag

public PeterO.Numbers.EDecimal RoundToIntegralNoRoundedFlag(
    PeterO.Numbers.EContext ctx);

Deprecated. 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:

Return Value:

An arbitrary-precision decimal number rounded to the closest integer representable in the given 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 of the valid range of the arithmetic context.

### RoundToPrecision

public PeterO.Numbers.EDecimal RoundToPrecision(
    PeterO.Numbers.EContext ctx);

Rounds this object’s value to a given precision, using the given rounding mode and range of exponent.

Parameters:

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.

### ScaleByPowerOfTen

public PeterO.Numbers.EDecimal ScaleByPowerOfTen(
    int places);

Returns a number similar to this number but with the scale adjusted.

Parameters:

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.

### ScaleByPowerOfTen

public PeterO.Numbers.EDecimal ScaleByPowerOfTen(
    int places,
    PeterO.Numbers.EContext ctx);

Returns a number similar to this number but with the scale adjusted.

Parameters:

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.

### ScaleByPowerOfTen

public PeterO.Numbers.EDecimal ScaleByPowerOfTen(
    PeterO.Numbers.EInteger bigPlaces);

Returns a number similar to this number but with the scale adjusted.

Parameters:

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.

### ScaleByPowerOfTen

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:

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:

### Sqrt

public PeterO.Numbers.EDecimal Sqrt(
    PeterO.Numbers.EContext ctx);

Finds the square root of this object’s value.

Parameters:

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).

### SquareRoot

public PeterO.Numbers.EDecimal SquareRoot(
    PeterO.Numbers.EContext ctx);

Deprecated. Renamed to Sqrt.

Finds the square root of this object’s value.

Parameters:

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).

### Subtract

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:

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.

### Subtract

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:

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.

### Subtract

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:

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.

### Subtract

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:

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:

### ToByteChecked

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:

### ToByteIfExact

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:

### ToByteUnchecked

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.

### ToDecimal

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).

### ToDouble

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.

### ToDoubleBits

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.

### ToEFloat

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:

Return Value:

An arbitrary-precision floating-point number.

### ToEFloat

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.

### ToEInteger

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:

### ToEIntegerExact

public PeterO.Numbers.EInteger ToEIntegerExact();

Deprecated. 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:

### ToEIntegerIfExact

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:

### ToEngineeringString

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.

### ToExtendedFloat

public PeterO.Numbers.EFloat ToExtendedFloat();

Deprecated. 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.

### ToHalfBits

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.

### ToInt16Checked

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:

### ToInt16IfExact

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:

### ToInt16Unchecked

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.

### ToInt32Checked

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:

### ToInt32IfExact

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:

### ToInt32Unchecked

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.

### ToInt64Checked

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:

### ToInt64IfExact

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:

### ToInt64Unchecked

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.

### ToPlainString

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.

### ToSByteChecked

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:

### ToSByteIfExact

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:

### ToSByteUnchecked

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.

### ToSingle

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.

### ToSingleBits

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.

### ToSizedEInteger

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 given signed bit count.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### ToSizedEIntegerIfExact

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 given signed bit count.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### ToString

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.

### ToUInt16Checked

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:

### ToUInt16IfExact

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:

### ToUInt16Unchecked

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.

### ToUInt32Checked

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:

### ToUInt32IfExact

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:

### ToUInt32Unchecked

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.

### ToUInt64Checked

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:

### ToUInt64IfExact

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:

### ToUInt64Unchecked

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.

### Ulp

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.

Back to Numbers start page.