PeterO.Numbers.EFloat

## PeterO.Numbers.EFloat

public sealed class EFloat :
    System.IComparable,
    System.IEquatable

Represents an arbitrary-precision binary 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.) Each number consists of an integer significand and an integer exponent, both arbitrary-precision. The value of the number equals significand * 2^exponent. This class also supports values for negative zero, not-a-number (NaN) values, and infinity. 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.

Unless noted otherwise, passing a null arbitrary-precision binary floating-point number 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 operation’s trap is enabled in the arithmetic context (see EContext’s Traps property).

An arbitrary-precision binary floating-point number value can be serialized in one of the following ways:

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.

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

See the reproducibility note in the EDecimal class’s documentation.

Member Summary

### NaN

public static readonly PeterO.Numbers.EFloat NaN;

A not-a-number value.

### NegativeInfinity

public static readonly PeterO.Numbers.EFloat NegativeInfinity;

Negative infinity, less than any other number.

### NegativeZero

public static readonly PeterO.Numbers.EFloat NegativeZero;

Represents the number negative zero.

### One

public static readonly PeterO.Numbers.EFloat One;

Represents the number 1.

### PositiveInfinity

public static readonly PeterO.Numbers.EFloat PositiveInfinity;

Positive infinity, greater than any other number.

### SignalingNaN

public static readonly PeterO.Numbers.EFloat 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 binary floating-point number.

### Ten

public static readonly PeterO.Numbers.EFloat Ten;

Represents the number 10.

### Zero

public static readonly PeterO.Numbers.EFloat 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 not-a-number, NaN).

Returns:

true if this object is finite (not infinity or not-a-number, 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.EFloat 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.EFloat Abs();

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

Return Value:

An arbitrary-precision binary floating-point 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.EFloat Add(
    int intValue);

Adds this arbitrary-precision binary 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 binary 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 binary floating-point number plus a 32-bit signed integer. If this arbitrary-precision binary floating-point number is not-a-number (NaN), returns NaN.

### Add

public PeterO.Numbers.EFloat Add(
    long longValue);

Adds this arbitrary-precision binary 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 binary 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 binary floating-point number plus a 64-bit signed integer. If this arbitrary-precision binary floating-point number is not-a-number (NaN), returns NaN.

### Add

public PeterO.Numbers.EFloat Add(
    PeterO.Numbers.EFloat otherValue);

Adds this arbitrary-precision binary floating-point number and another arbitrary-precision binary floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision binary floating-point number’s exponent and the other arbitrary-precision binary floating-point number’s exponent.

Parameters:

Return Value:

The sum of the two numbers, that is, this arbitrary-precision binary floating-point number plus another arbitrary-precision binary floating-point number. If this arbitrary-precision binary floating-point number is not-a-number (NaN), returns NaN.

### Add

public PeterO.Numbers.EFloat Add(
    PeterO.Numbers.EFloat otherValue,
    PeterO.Numbers.EContext ctx);

Adds this arbitrary-precision binary floating-point number and another arbitrary-precision binary floating-point number and returns the result.

Parameters:

Return Value:

The sum of the two numbers, that is, this arbitrary-precision binary floating-point number plus another arbitrary-precision binary floating-point number. If this arbitrary-precision binary 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.EFloat 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.

### CompareToSignal

public PeterO.Numbers.EFloat CompareToSignal(
    PeterO.Numbers.EFloat 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 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.EFloat 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.EFloat 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.EFloat 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, 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.

.

### CompareToTotalMagnitude

public int CompareToTotalMagnitude(
    PeterO.Numbers.EFloat 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.

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

### CompareToWithContext

public PeterO.Numbers.EFloat CompareToWithContext(
    PeterO.Numbers.EFloat 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.EFloat Copy();

Creates a copy of this arbitrary-precision binary number.

Return Value:

An arbitrary-precision binary floating-point number.

### CopySign

public PeterO.Numbers.EFloat CopySign(
    PeterO.Numbers.EFloat 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 binary floating-point number.

Exceptions:

### Create

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

Returns an arbitrary-precision number with the value exponent*2^significand .

Parameters:

Return Value:

An arbitrary-precision binary number.

### Create

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

Returns an arbitrary-precision number with the value exponent*2^significand .

Parameters:

Return Value:

An arbitrary-precision binary number.

### Create

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

Returns an arbitrary-precision number with the value exponent*2^significand .

Parameters:

Return Value:

An arbitrary-precision binary number.

### Create

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

Returns an arbitrary-precision number with the value exponent*2^significand .

Parameters:

Return Value:

An arbitrary-precision binary number.

Exceptions:

### Create

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

Returns an arbitrary-precision number with the value exponent*2^significand .

Parameters:

Return Value:

An arbitrary-precision binary number.

Exceptions:

### Create

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

Returns an arbitrary-precision number with the value exponent*2^significand .

Parameters:

Return Value:

An arbitrary-precision binary number.

Exceptions:

### CreateNaN

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

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

Parameters:

Return Value:

A quiet not-a-number.

### CreateNaN

public static PeterO.Numbers.EFloat CreateNaN(
    PeterO.Numbers.EInteger diag,
    bool signaling,
    bool negative,
    PeterO.Numbers.EContext ctx);

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

Parameters:

Return Value:

An arbitrary-precision binary number.

Exceptions:

### Decrement

public PeterO.Numbers.EFloat Decrement();

Returns one subtracted from this arbitrary-precision binary floating-point number.

Return Value:

The given arbitrary-precision binary floating-point number minus one.

### Divide

public PeterO.Numbers.EFloat Divide(
    int intValue);

Divides this arbitrary-precision binary floating-point number by a 32-bit signed integer and returns the result; returns NaN instead if the result would have a nonterminating binary 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 binary floating-point number by a 32-bit signed integer. Returns infinity if the divisor (this arbitrary-precision binary 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 binary 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.Binary64 ) instead.

Exceptions:

### Divide

public PeterO.Numbers.EFloat Divide(
    long longValue);

Divides this arbitrary-precision binary floating-point number by a 64-bit signed integer and returns the result; returns NaN instead if the result would have a nonterminating binary 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 binary floating-point number by a 64-bit signed integer. Returns infinity if the divisor (this arbitrary-precision binary 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 binary 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.Binary64 ) instead.

Exceptions:

### Divide

public PeterO.Numbers.EFloat Divide(
    PeterO.Numbers.EFloat divisor);

Divides this arbitrary-precision binary floating-point number by another arbitrary-precision binary floating-point number and returns the result; returns NaN instead if the result would have a nonterminating binary 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 binary floating-point number by another arbitrary-precision binary floating-point number. Returns infinity if the divisor (this arbitrary-precision binary floating-point number) is 0 and the dividend (the other arbitrary-precision binary 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 binary 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.Binary64 ) instead.

### Divide

public PeterO.Numbers.EFloat Divide(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EContext ctx);

Divides this arbitrary-precision binary floating-point number by another arbitrary-precision binary floating-point number and returns the result.

Parameters:

Return Value:

The result of dividing this arbitrary-precision binary floating-point number by another arbitrary-precision binary floating-point number. Signals FlagDivideByZero and returns infinity if the divisor (this arbitrary-precision binary floating-point number) is 0 and the dividend (the other arbitrary-precision binary 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 binary 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.EFloat[] DivideAndRemainderNaturalScale(
    PeterO.Numbers.EFloat 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.EFloat[] DivideAndRemainderNaturalScale(
    PeterO.Numbers.EFloat 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.EFloat DivideToExponent(
    PeterO.Numbers.EFloat divisor,
    long desiredExponentSmall,
    PeterO.Numbers.EContext ctx);

Divides two arbitrary-precision binary floating-point 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.EFloat DivideToExponent(
    PeterO.Numbers.EFloat divisor,
    long desiredExponentSmall,
    PeterO.Numbers.ERounding rounding);

Divides two arbitrary-precision binary floating-point 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.EFloat DivideToExponent(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EInteger desiredExponent,
    PeterO.Numbers.ERounding rounding);

Divides two arbitrary-precision binary floating-point 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.EFloat DivideToExponent(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EInteger exponent,
    PeterO.Numbers.EContext ctx);

Divides two arbitrary-precision binary floating-point 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.EFloat DivideToIntegerNaturalScale(
    PeterO.Numbers.EFloat divisor);

Divides two arbitrary-precision binary floating-point 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.EFloat DivideToIntegerNaturalScale(
    PeterO.Numbers.EFloat 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.EFloat DivideToIntegerZeroScale(
    PeterO.Numbers.EFloat 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.EFloat DivideToSameExponent(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.ERounding rounding);

Divides this object by another binary floating-point 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.EFloat[] DivRemNaturalScale(
    PeterO.Numbers.EFloat divisor);

Divides this arbitrary-precision binary floating-point number by another arbitrary-precision binary 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 binary floating-point number, and the second is the remainder as an arbitrary-precision binary 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.EFloat[] DivRemNaturalScale(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EContext ctx);

Divides this arbitrary-precision binary floating-point number by another arbitrary-precision binary 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 binary floating-point number, and the second is the remainder as an arbitrary-precision binary 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 binary floating-point 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.EFloat 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 .

### EqualsInternal

public bool EqualsInternal(
    PeterO.Numbers.EFloat otherValue);

Determines whether this object’s significand and exponent are equal to those of another object.

Parameters:

Return Value:

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

### Exp

public PeterO.Numbers.EFloat 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.EFloat 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.EFloat FromBoolean(
    bool boolValue);

Converts a boolean value (either true or false) to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

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

### FromByte

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

Converts a byte (from 0 to 255) to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point number.

### FromDouble

public static PeterO.Numbers.EFloat FromDouble(
    double dbl);

Creates a binary floating-point number from a 64-bit 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. 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, EFloat.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:

A binary floating-point number with the same value as dbl .

### FromDoubleBits

public static PeterO.Numbers.EFloat FromDoubleBits(
    long dblBits);

Creates a binary floating-point number from a 64-bit 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.

Parameters:

Return Value:

A binary floating-point number with the same value as the floating-point number encoded in dblBits .

### FromEInteger

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

Converts an arbitrary-precision integer to the same value as a binary floating-point number.

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

### FromHalfBits

public static PeterO.Numbers.EFloat FromHalfBits(
    short value);

Creates a binary 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 binary floating-point number with the same floating-point value as value .

### FromInt16

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

Converts a 16-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point number.

### FromInt32

public static PeterO.Numbers.EFloat FromInt32(
    int inputInt32);

Converts a 32-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point number.

### FromInt64

public static PeterO.Numbers.EFloat FromInt64(
    long inputInt64);

Converts a 64-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

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

### FromInt64AsUnsigned

public static PeterO.Numbers.EFloat FromInt64AsUnsigned(
    long longerValue);

Converts an unsigned integer expressed as a 64-bit signed integer to an arbitrary-precision binary number.

Parameters:

Return Value:

An arbitrary-precision binary 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.EFloat FromSByte(
    sbyte inputSByte);

This API is not CLS-compliant.

Converts an 8-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point number.

### FromSingle

public static PeterO.Numbers.EFloat FromSingle(
    float flt);

Creates a binary floating-point number from a 32-bit 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. 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, EFloat.FromSingle(Single.NaN) or EFloat.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:

A binary floating-point number with the same value as flt .

### FromSingleBits

public static PeterO.Numbers.EFloat FromSingleBits(
    int value);

Creates a binary floating-point number from a 32-bit 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.

Parameters:

Return Value:

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

### FromString

public static PeterO.Numbers.EFloat FromString(
    byte[] bytes);

Creates a binary floating-point number from a sequence of bytes that represents a number, using an unlimited precision context. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    byte[] bytes,
    int offset,
    int length);

Creates a binary floating-point number from a sequence of bytes that represents a number. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    byte[] bytes,
    int offset,
    int length,
    PeterO.Numbers.EContext ctx);

Creates a binary floating-point number from a sequence of bytes that represents a number. Note that if the sequence 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. The format of the sequence generally consists of:

The sequence can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN”) followed by any number of digits (these digits may begin with any number of zeros), or signaling NaN (“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:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    byte[] bytes,
    PeterO.Numbers.EContext ctx);

Creates a binary floating-point number from a sequence of bytes that represents a number. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    char[] chars);

Creates a binary floating-point number from a sequence of char s that represents a number, using an unlimited precision context. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    char[] chars,
    int offset,
    int length);

Creates a binary floating-point number from a sequence of char s that represents a number. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    char[] chars,
    int offset,
    int length,
    PeterO.Numbers.EContext ctx);

Creates a binary floating-point number from a sequence of char s that represents a number. Note that if the sequence 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. The format of the sequence generally consists of:

The sequence can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN”) followed by any number of digits (these digits may begin with any number of zeros), or signaling NaN (“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:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    char[] chars,
    PeterO.Numbers.EContext ctx);

Creates a binary floating-point number from a sequence of char s that represents a number. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    string str);

Creates a binary floating-point number from a text string that represents a number, using an unlimited precision context. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    string str,
    int offset,
    int length);

Creates a binary floating-point number from a text string that represents a number. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    string str,
    int offset,
    int length,
    PeterO.Numbers.EContext ctx);

Creates a binary floating-point number from a text string that represents a number. Note that if the string 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. The format of the string generally consists of:

The string can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN”) followed by any number of digits (these digits may begin with any number of zeros), or signaling NaN (“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:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromString

public static PeterO.Numbers.EFloat FromString(
    string str,
    PeterO.Numbers.EContext ctx);

Creates a binary floating-point number from a text string that represents a number. For more information, see the FromString(String, int, int, EContext) method.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary floating-point number.

Exceptions:

### FromUInt16

public static PeterO.Numbers.EFloat FromUInt16(
    ushort inputUInt16);

This API is not CLS-compliant.

Converts a 16-bit unsigned integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point number.

### FromUInt32

public static PeterO.Numbers.EFloat FromUInt32(
    uint inputUInt32);

This API is not CLS-compliant.

Converts a 32-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point number.

### FromUInt64

public static PeterO.Numbers.EFloat FromUInt64(
    ulong inputUInt64);

This API is not CLS-compliant.

Converts a 64-bit unsigned integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

This number’s value as an arbitrary-precision binary floating-point 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.EFloat Increment();

Returns one added to this arbitrary-precision binary floating-point number.

Return Value:

The given arbitrary-precision binary floating-point 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.EFloat 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.EFloat 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.EFloat 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.EFloat LogN(
    PeterO.Numbers.EFloat 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.EFloat Max(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat second);

Gets the greater value between two binary floating-point 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.EFloat Max(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat second,
    PeterO.Numbers.EContext ctx);

Gets the greater value between two binary floating-point 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.EFloat MaxMagnitude(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat 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.EFloat MaxMagnitude(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat 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.EFloat Min(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat second);

Gets the lesser value between two binary floating-point 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.EFloat Min(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat second,
    PeterO.Numbers.EContext ctx);

Gets the lesser value between two binary floating-point 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.EFloat MinMagnitude(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat 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.EFloat MinMagnitude(
    PeterO.Numbers.EFloat first,
    PeterO.Numbers.EFloat 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.EFloat MovePointLeft(
    int places);

Returns a number similar to this number but with the radix 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.EFloat MovePointLeft(
    int places,
    PeterO.Numbers.EContext ctx);

Returns a number similar to this number but with the radix 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.EFloat MovePointLeft(
    PeterO.Numbers.EInteger bigPlaces);

Returns a number similar to this number but with the radix 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.EFloat MovePointLeft(
    PeterO.Numbers.EInteger bigPlaces,
    PeterO.Numbers.EContext ctx);

Returns a number similar to this number but with the radix 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.EFloat MovePointRight(
    int places);

Returns a number similar to this number but with the radix 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.EFloat MovePointRight(
    int places,
    PeterO.Numbers.EContext ctx);

Returns a number similar to this number but with the radix 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.EFloat MovePointRight(
    PeterO.Numbers.EInteger bigPlaces);

Returns a number similar to this number but with the radix 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.EFloat MovePointRight(
    PeterO.Numbers.EInteger bigPlaces,
    PeterO.Numbers.EContext ctx);

Returns a number similar to this number but with the radix 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.EFloat Multiply(
    int intValue);

Multiplies this arbitrary-precision binary floating-point number by a 32-bit signed integer and returns the result. The exponent for the result is this arbitrary-precision binary floating-point number’s exponent plus the other 32-bit signed integer’s exponent.

EInteger result = EInteger.FromString("5").Multiply(200);

.

Parameters:

Return Value:

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

### Multiply

public PeterO.Numbers.EFloat Multiply(
    long longValue);

Multiplies this arbitrary-precision binary floating-point number by a 64-bit signed integer and returns the result. The exponent for the result is this arbitrary-precision binary floating-point number’s exponent plus the other 64-bit signed integer’s exponent.

EInteger result = EInteger.FromString("5").Multiply(200L);

.

Parameters:

Return Value:

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

### Multiply

public PeterO.Numbers.EFloat Multiply(
    PeterO.Numbers.EFloat op,
    PeterO.Numbers.EContext ctx);

Multiplies this arbitrary-precision binary floating-point number by another arbitrary-precision binary floating-point number and returns the result.

Parameters:

Return Value:

The product of the two numbers, that is, this arbitrary-precision binary floating-point number times another arbitrary-precision binary floating-point number.

### Multiply

public PeterO.Numbers.EFloat Multiply(
    PeterO.Numbers.EFloat otherValue);

Multiplies this arbitrary-precision binary floating-point number by another arbitrary-precision binary floating-point number and returns the result. The exponent for the result is this arbitrary-precision binary floating-point number’s exponent plus the other arbitrary-precision binary floating-point number’s exponent.

Parameters:

Return Value:

The product of the two numbers, that is, this arbitrary-precision binary floating-point number times another arbitrary-precision binary floating-point number.

Exceptions:

### MultiplyAndAdd

public PeterO.Numbers.EFloat MultiplyAndAdd(
    PeterO.Numbers.EFloat multiplicand,
    PeterO.Numbers.EFloat augend);

Multiplies by one binary floating-point number, and then adds another binary floating-point number.

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

### MultiplyAndAdd

public PeterO.Numbers.EFloat MultiplyAndAdd(
    PeterO.Numbers.EFloat op,
    PeterO.Numbers.EFloat 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.EFloat MultiplyAndSubtract(
    PeterO.Numbers.EFloat op,
    PeterO.Numbers.EFloat 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.EFloat Negate(
    PeterO.Numbers.EContext context);

Returns a binary floating-point number with the same value as this object but with the sign reversed.

Parameters:

Return Value:

An arbitrary-precision binary floating-point 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.EFloat Negate();

Gets an object with the same value as this one, but with the sign reversed.

Return Value:

An arbitrary-precision binary floating-point 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.EFloat 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.EFloat 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.EFloat NextToward(
    PeterO.Numbers.EFloat 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.EFloat operator +(
    PeterO.Numbers.EFloat bthis,
    PeterO.Numbers.EFloat otherValue);

Adds an arbitrary-precision binary floating-point number and another arbitrary-precision binary floating-point number and returns the result.

Parameters:

Return Value:

The sum of the two numbers, that is, an arbitrary-precision binary floating-point number plus another arbitrary-precision binary floating-point number.

Exceptions:

### Operator --

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

Subtracts one from an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The number given in bthis minus one.

Exceptions:

### Operator /

public static PeterO.Numbers.EFloat operator /(
    PeterO.Numbers.EFloat dividend,
    PeterO.Numbers.EFloat divisor);

Divides one binary floating-point number by another 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 binary expansion. 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.EFloat input);

Converts an arbitrary-precision binary floating-point 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 double(
    PeterO.Numbers.EFloat 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.EFloat bigValue);

Converts an arbitrary-precision binary floating-point number 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.EFloat input);

Converts an arbitrary-precision binary floating-point 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.EFloat input);

Converts an arbitrary-precision binary floating-point 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.EFloat(
    bool boolValue);

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

Parameters:

Return Value:

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

### Explicit Operator

public static explicit operator PeterO.Numbers.EInteger(
    PeterO.Numbers.EFloat bigValue);

Converts an arbitrary-precision binary floating-point number to a value 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.EFloat input);

This API is not CLS-compliant.

Converts an arbitrary-precision binary floating-point 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.EFloat input);

Converts an arbitrary-precision binary floating-point 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.EFloat input);

This API is not CLS-compliant.

Converts an arbitrary-precision binary floating-point 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.EFloat input);

This API is not CLS-compliant.

Converts an arbitrary-precision binary floating-point 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.EFloat input);

This API is not CLS-compliant.

Converts an arbitrary-precision binary floating-point 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.EFloat(
    byte inputByte);

Converts a byte (from 0 to 255) to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputByte as an arbitrary-precision binary floating-point number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EFloat(
    double dbl);

Creates a binary floating-point number from a 64-bit 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 binary floating-point number with the same value as dbl .

### Implicit Operator

public static implicit operator PeterO.Numbers.EFloat(
    float flt);

Creates a binary floating-point number from a 32-bit 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 binary floating-point number with the same value as flt .

### Implicit Operator

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

Converts a 32-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputInt32 as an arbitrary-precision binary floating-point number.

### Implicit Operator

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

Converts a 64-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputInt64 as an arbitrary-precision binary floating-point number.

### Implicit Operator

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

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

Parameters:

Return Value:

An arbitrary-precision binary floating-point number with the exponent set to 0.

### Implicit Operator

public static implicit operator PeterO.Numbers.EFloat(
    sbyte inputSByte);

This API is not CLS-compliant.

Converts an 8-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputSByte as an arbitrary-precision binary floating-point number.

### Implicit Operator

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

Converts a 16-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputInt16 as an arbitrary-precision binary floating-point number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EFloat(
    uint inputUInt32);

This API is not CLS-compliant.

Converts a 32-bit signed integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputUInt32 as an arbitrary-precision binary floating-point number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EFloat(
    ulong inputUInt64);

This API is not CLS-compliant.

Converts a 64-bit unsigned integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputUInt64 as an arbitrary-precision binary floating-point number.

### Implicit Operator

public static implicit operator PeterO.Numbers.EFloat(
    ushort inputUInt16);

This API is not CLS-compliant.

Converts a 16-bit unsigned integer to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The value of inputUInt16 as an arbitrary-precision binary floating-point number.

### Operator ++

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

Adds one to an arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The number given in bthis plus one.

Exceptions:

### Operator %

public static PeterO.Numbers.EFloat operator %(
    PeterO.Numbers.EFloat dividend,
    PeterO.Numbers.EFloat divisor);

Returns the remainder that would result when an arbitrary-precision binary floating-point number is divided by another arbitrary-precision binary floating-point number. The remainder is the number that remains when the absolute value of an arbitrary-precision binary floating-point number is divided (as though by DivideToIntegerZeroScale) by the absolute value of the other arbitrary-precision binary floating-point number; the remainder has the same sign (positive or negative) as this arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The remainder that would result when an arbitrary-precision binary floating-point number is divided by another arbitrary-precision binary floating-point number.

Exceptions:

### Operator *

public static PeterO.Numbers.EFloat operator *(
    PeterO.Numbers.EFloat operand1,
    PeterO.Numbers.EFloat operand2);

Multiplies an arbitrary-precision binary floating-point number by another arbitrary-precision binary floating-point number and returns the result.

Parameters:

Return Value:

The product of the two numbers, that is, an arbitrary-precision binary floating-point number times another arbitrary-precision binary floating-point number.

Exceptions:

### Operator -

public static PeterO.Numbers.EFloat operator -(
    PeterO.Numbers.EFloat bthis,
    PeterO.Numbers.EFloat subtrahend);

Subtracts one arbitrary-precision binary floating-point number from another.

Parameters:

Return Value:

The difference of the two objects.

Exceptions:

### Operator -

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

Gets an object with the same value as this one, but with the sign reversed.

Parameters:

Return Value:

The negated form of the given number. If the given number is positive zero, returns negative zero. Returns signaling NaN if this value is signaling NaN.

Exceptions:

### PI

public static PeterO.Numbers.EFloat 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.EFloat 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.EFloat 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.EFloat 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.EFloat Pow(
    PeterO.Numbers.EFloat 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.EFloat Pow(
    PeterO.Numbers.EFloat 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.EFloat 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.EFloat Quantize(
    int desiredExponentInt,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point number with the same value but a new exponent. Note that this is not always the same as rounding to a given number of binary digit 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 binary digit places is desired, it’s better to use the RoundToExponent and RoundToIntegral methods instead.

Remark: This method can be used to implement fixed-point binary arithmetic, in which each binary floating-point number has a fixed number of digits after the radix point. The following code example returns a fixed-point number with up to 20 digits before and exactly 5 digits after the radix point:

 /* After performing arithmetic operations, adjust
            /* the number to 5*/*/
            digits after the radix point number = number.Quantize(-5, /* five
            digits*/
            after the radix point EContext.ForPrecision(25) /* 25-digit
            precision);*/

A fixed-point binary arithmetic in which no digits come after the radix point (a desired exponent of 0) is considered an “integer arithmetic”.

Parameters:

Return Value:

A binary floating-point 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.EFloat Quantize(
    PeterO.Numbers.EFloat otherValue,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point number with the same value as this object but with the same exponent as another binary floating-point number. Note that this is not always the same as rounding to a given number of binary digit 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 binary digit places is desired, it’s better to use the RoundToExponent and RoundToIntegral methods instead.

Remark: This method can be used to implement fixed-point binary arithmetic, in which a fixed number of digits come after the radix point. A fixed-point binary arithmetic in which no digits come after the radix point (a desired exponent of 0) is considered an “integer arithmetic” .

Parameters:

Return Value:

A binary floating-point 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.EFloat Quantize(
    PeterO.Numbers.EInteger desiredExponent,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point number with the same value but a new exponent. Note that this is not always the same as rounding to a given number of binary digit 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 binary digit places is desired, it’s better to use the RoundToExponent and RoundToIntegral methods instead.

Remark: This method can be used to implement fixed-point binary arithmetic, in which each binary floating-point number has a fixed number of digits after the radix point. The following code example returns a fixed-point number with up to 20 digits before and exactly 5 digits after the radix point:

 /* After performing arithmetic operations, adjust
            /* the number to 5 /*
            */*/*/
            digits after the radix point number = number.Quantize(
            EInteger.FromInt32(-5), /* five digits after the radix
            point*/
            EContext.ForPrecision(25) /* 25-digit
            precision);*/

A fixed-point binary arithmetic in which no digits come after the radix point (a desired exponent of 0) is considered an “integer arithmetic”.

Parameters:

Return Value:

A binary floating-point 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.EFloat 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.EFloat Remainder(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EContext ctx);

Returns the remainder that would result when this arbitrary-precision binary floating-point number is divided by another arbitrary-precision binary floating-point number. The remainder is the number that remains when the absolute value of this arbitrary-precision binary floating-point number is divided (as though by DivideToIntegerZeroScale) by the absolute value of the other arbitrary-precision binary floating-point number; the remainder has the same sign (positive or negative) as this arbitrary-precision binary floating-point number.

Parameters:

Return Value:

The remainder that would result when this arbitrary-precision binary floating-point number is divided by another arbitrary-precision binary floating-point number. Signals FlagDivideByZero and returns infinity if the divisor (this arbitrary-precision binary floating-point number) is 0 and the dividend (the other arbitrary-precision binary 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.EFloat RemainderNaturalScale(
    PeterO.Numbers.EFloat divisor);

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

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

### RemainderNaturalScale

public PeterO.Numbers.EFloat RemainderNaturalScale(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EContext ctx);

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

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

### RemainderNear

public PeterO.Numbers.EFloat RemainderNear(
    PeterO.Numbers.EFloat 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.EFloat RemainderNoRoundAfterDivide(
    PeterO.Numbers.EFloat divisor,
    PeterO.Numbers.EContext ctx);

Finds the remainder that results when dividing two arbitrary-precision binary floating-point numbers. The remainder is the value that remains when the absolute 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.EFloat RoundToExponent(
    int exponentSmall,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point 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:

A binary floating-point 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.EFloat RoundToExponent(
    PeterO.Numbers.EInteger exponent,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point 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:

A binary floating-point 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.

### RoundToExponentExact

public PeterO.Numbers.EFloat RoundToExponentExact(
    int exponentSmall,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point 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:

A binary floating-point 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.EFloat RoundToExponentExact(
    PeterO.Numbers.EInteger exponent,
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point number with the same value as this object but rounded to the given exponent, 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:

A binary floating-point 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.EFloat RoundToExponentExact(
    PeterO.Numbers.EInteger exponent,
    PeterO.Numbers.ERounding rounding);

Returns a binary number with the same value as this object but rounded to the given exponent. 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:

A binary number rounded to the closest value representable in the given precision.

### RoundToIntegerExact

public PeterO.Numbers.EFloat RoundToIntegerExact(
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point 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:

A binary floating-point 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.EFloat RoundToIntegerNoRoundedFlag(
    PeterO.Numbers.EContext ctx);

Returns a binary floating-point 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:

A binary floating-point 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.EFloat RoundToIntegralExact(
    PeterO.Numbers.EContext ctx);

Deprecated. Renamed to RoundToIntegerExact.

Returns a binary floating-point 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:

A binary floating-point 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.EFloat RoundToIntegralNoRoundedFlag(
    PeterO.Numbers.EContext ctx);

Deprecated. Renamed to RoundToIntegerNoRoundedFlag.

Returns a binary floating-point number with the same value as this object but rounded to an integer, without adding the FlagInexact or FlagRounded flags.

Parameters:

Return Value:

A binary floating-point 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.EFloat 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.

### ScaleByPowerOfTwo

public PeterO.Numbers.EFloat ScaleByPowerOfTwo(
    int places);

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

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

### ScaleByPowerOfTwo

public PeterO.Numbers.EFloat ScaleByPowerOfTwo(
    int places,
    PeterO.Numbers.EContext ctx);

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

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

### ScaleByPowerOfTwo

public PeterO.Numbers.EFloat ScaleByPowerOfTwo(
    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 .

### ScaleByPowerOfTwo

public PeterO.Numbers.EFloat ScaleByPowerOfTwo(
    PeterO.Numbers.EInteger bigPlaces,
    PeterO.Numbers.EContext ctx);

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

Parameters:

Return Value:

An arbitrary-precision binary floating-point number.

Exceptions:

### Sqrt

public PeterO.Numbers.EFloat 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.EFloat 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.EFloat Subtract(
    int intValue);

Subtracts a 32-bit signed integer from this arbitrary-precision binary floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision binary 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 binary floating-point number minus a 32-bit signed integer. If this arbitrary-precision binary floating-point number is not-a-number (NaN), returns NaN.

### Subtract

public PeterO.Numbers.EFloat Subtract(
    long longValue);

Subtracts a 64-bit signed integer from this arbitrary-precision binary floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision binary 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 binary floating-point number minus a 64-bit signed integer. If this arbitrary-precision binary floating-point number is not-a-number (NaN), returns NaN.

### Subtract

public PeterO.Numbers.EFloat Subtract(
    PeterO.Numbers.EFloat otherValue);

Subtracts an arbitrary-precision binary floating-point number from this arbitrary-precision binary floating-point number and returns the result. The exponent for the result is the lower of this arbitrary-precision binary floating-point number’s exponent and the other arbitrary-precision binary floating-point number’s exponent.

Parameters:

Return Value:

The difference between the two numbers, that is, this arbitrary-precision binary floating-point number minus another arbitrary-precision binary floating-point number. If this arbitrary-precision binary floating-point number is not-a-number (NaN), returns NaN.

### Subtract

public PeterO.Numbers.EFloat Subtract(
    PeterO.Numbers.EFloat otherValue,
    PeterO.Numbers.EContext ctx);

Subtracts an arbitrary-precision binary floating-point number from this arbitrary-precision binary floating-point number and returns the result.

Parameters:

Return Value:

The difference between the two numbers, that is, this arbitrary-precision binary floating-point number minus another arbitrary-precision binary floating-point number. If this arbitrary-precision binary 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.

### ToDouble

public double ToDouble();

Converts this value to a 64-bit floating-point number encoded in the IEEE 754 binary64 format.

Return Value:

This number, converted to a 64-bit floating-point number encoded in the IEEE 754 binary64 format. 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, expressed as an integer in the IEEE 754 binary64 format. 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.

Return Value:

The closest 64-bit binary floating-point number to this value, expressed as an integer in the IEEE 754 binary64 format. The return value can be positive infinity or negative infinity if this value exceeds the range of a 64-bit floating point number.

### ToEDecimal

public PeterO.Numbers.EDecimal ToEDecimal();

Converts this value to an arbitrary-precision decimal number.

Return Value:

This number, converted to an arbitrary-precision decimal number.

### ToEInteger

public PeterO.Numbers.EInteger ToEInteger();

Converts this value to an arbitrary-precision integer. Any fractional part of this value will be discarded when converting to an arbitrary-precision integer. 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 value contains a fractional part. 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 value contains a fractional part. 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();

Converts this value to an arbitrary-precision decimal number, then returns the value of that decimal’s ToEngineeringString method.

Return Value:

A text string.

### ToExtendedDecimal

public PeterO.Numbers.EDecimal ToExtendedDecimal();

Deprecated. Renamed to ToEDecimal.

Converts this value to an arbitrary-precision decimal number.

Return Value:

An arbitrary-precision decimal 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, but without 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.

### ToShortestString

public string ToShortestString(
    PeterO.Numbers.EContext ctx);

Returns a string representation of this number’s value after rounding that value to the given precision (using the given arithmetic context, such as EContext.Binary64 ). If the number after rounding is neither infinity nor not-a-number (NaN), returns the shortest decimal form of this number’s value (in terms of decimal digits starting with the first nonzero digit and ending with the last nonzero digit) that results in the rounded number after the decimal form is converted to binary floating-point format (using the given arithmetic context).

The following example converts an EFloat number to its shortest round-tripping decimal form using the same precision as the double type in Java and.NET:

 String str = efloat.ToShortestString(EContext.Binary64);

Parameters:

Return Value:

Shortest decimal form of this number’s value for the given arithmetic context. 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 the number’s first nonzero decimal digit is more than five digits after the decimal point, or if the number’s exponent is greater than 0 and its value is 10, 000, 000 or greater.

### ToSingle

public float ToSingle();

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.

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 32-bit floating-point number, expressed as an integer in the IEEE 754 binary32 format. 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.

Return Value:

The closest 32-bit binary floating-point number to this value, expressed as an integer 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 number’s value to a text string.

Return Value:

A string representation of this object. The value is converted to a decimal number (using the EDecimal.FromEFloat method) and the decimal form of this number’s value is returned. 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 the converted decimal number’s exponent (EDecimal’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.EFloat 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 binary floating-point number.

Back to Numbers start page.