PeterO.Numbers.ERational
## PeterO.Numbers.ERational
public sealed class ERational : System.IComparable, System.IEquatable
Represents an arbitrary-precision rational number. This class can’t be inherited. (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.) In this class, a rational number consists of a numerator and denominator, each an arbitrary-precision integer (EInteger), and this class does not automatically convert rational numbers to lowest terms. 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).
Member Summary
[Abs()](#Abs)
- Returns the absolute value of this rational number, that is, a number with the same value as this one but as a nonnegative number.[Add(int)](#Add_int)
- Adds this arbitrary-precision rational number and a 32-bit signed integer and returns the result.[Add(long)](#Add_long)
- Adds this arbitrary-precision rational number and a 64-bit signed integer and returns the result.[Add(PeterO.Numbers.ERational)](#Add_PeterO_Numbers_ERational)
- Adds this arbitrary-precision rational number and another arbitrary-precision rational number and returns the result.[CompareTo(int)](#CompareTo_int)
- Compares the mathematical value of an arbitrary-precision rational number with that of this instance.[CompareTo(long)](#CompareTo_long)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareTo(PeterO.Numbers.ERational)](#CompareTo_PeterO_Numbers_ERational)
- Compares the mathematical value of an arbitrary-precision rational number with that of this instance.[CompareToBinary(PeterO.Numbers.EFloat)](#CompareToBinary_PeterO_Numbers_EFloat)
- Compares an arbitrary-precision binary floating-point number with this instance.[CompareToDecimal(PeterO.Numbers.EDecimal)](#CompareToDecimal_PeterO_Numbers_EDecimal)
- Compares an arbitrary-precision decimal number with this instance.[CompareToTotal(PeterO.Numbers.ERational)](#CompareToTotal_PeterO_Numbers_ERational)
- Compares the values of this object and another object, imposing a total ordering on all possible values.[CompareToTotalMagnitude(PeterO.Numbers.ERational)](#CompareToTotalMagnitude_PeterO_Numbers_ERational)
- Compares the absolute values of this object and another object, imposing a total ordering on all possible values (ignoring their signs).[CompareToValue(int)](#CompareToValue_int)
- Compares the mathematical value of an arbitrary-precision rational number with that of this instance.[CompareToValue(long)](#CompareToValue_long)
- Compares the mathematical values of this object and another object, accepting NaN values.[CompareToValue(PeterO.Numbers.ERational)](#CompareToValue_PeterO_Numbers_ERational)
- Compares the mathematical value of an arbitrary-precision rational number with that of this instance.[Copy()](#Copy)
- Creates a copy of this arbitrary-precision rational number.[CopySign(PeterO.Numbers.ERational)](#CopySign_PeterO_Numbers_ERational)
- Returns a number with the same value as this one, but copying the sign (positive or negative) of another number.[Create(int, int)](#Create_int_int)
- Creates a rational number with the specified numerator and denominator.[Create(long, long)](#Create_long_long)
- Creates a rational number with the specified numerator and denominator.[Create(PeterO.Numbers.EInteger, PeterO.Numbers.EInteger)](#Create_PeterO_Numbers_EInteger_PeterO_Numbers_EInteger)
- Creates a rational number with the specified numerator and denominator.[CreateNaN(PeterO.Numbers.EInteger)](#CreateNaN_PeterO_Numbers_EInteger)
- Creates a not-a-number arbitrary-precision rational number.[CreateNaN(PeterO.Numbers.EInteger, bool, bool)](#CreateNaN_PeterO_Numbers_EInteger_bool_bool)
- Creates a not-a-number arbitrary-precision rational number.[Decrement()](#Decrement)
- Subtracts one from an arbitrary-precision rational number.[Denominator](#Denominator)
- Gets this object’s denominator.[Divide(int)](#Divide_int)
- Divides this arbitrary-precision rational number by a 32-bit signed integer and returns the result.[Divide(long)](#Divide_long)
- Divides this arbitrary-precision rational number by a 64-bit signed integer and returns the result.[Divide(PeterO.Numbers.ERational)](#Divide_PeterO_Numbers_ERational)
- Divides this arbitrary-precision rational number by another arbitrary-precision rational number and returns the result.[Equals(object)](#Equals_object)
- Determines whether this object’s numerator, denominator, and properties are equal to those of another object and that other object is an arbitrary-precision rational number.[Equals(PeterO.Numbers.ERational)](#Equals_PeterO_Numbers_ERational)
- Determines whether this object’s numerator, denominator, and properties are equal to those of another object.[explicit operator byte(PeterO.Numbers.ERational)](#explicit_operator_byte_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.[explicit operator decimal(PeterO.Numbers.ERational)](#explicit_operator_decimal_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a decimal under the Common Language Infrastructure (see T:PeterO.[explicit operator double(PeterO.Numbers.ERational)](#explicit_operator_double_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 64-bit floating-point number.[explicit operator float(PeterO.Numbers.ERational)](#explicit_operator_float_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 32-bit binary floating-point number.[explicit operator int(PeterO.Numbers.ERational)](#explicit_operator_int_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator long(PeterO.Numbers.ERational)](#explicit_operator_long_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator PeterO.Numbers.EInteger(PeterO.Numbers.ERational)](#explicit_operator_PeterO_Numbers_EInteger_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to an arbitrary-precision integer.[explicit operator PeterO.Numbers.ERational(bool)](#explicit_operator_PeterO_Numbers_ERational_bool)
- Converts a Boolean value (true or false) to an arbitrary-precision rational number.[explicit operator sbyte(PeterO.Numbers.ERational)](#explicit_operator_sbyte_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator short(PeterO.Numbers.ERational)](#explicit_operator_short_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator uint(PeterO.Numbers.ERational)](#explicit_operator_uint_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[explicit operator ulong(PeterO.Numbers.ERational)](#explicit_operator_ulong_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational number to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.[explicit operator ushort(PeterO.Numbers.ERational)](#explicit_operator_ushort_PeterO_Numbers_ERational)
- Converts an arbitrary-precision rational 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.[FromBoolean(bool)](#FromBoolean_bool)
- Converts a Boolean value (true or false) to an arbitrary-precision rational number.[FromByte(byte)](#FromByte_byte)
- Converts a byte (from 0 to 255) to an arbitrary-precision rational number.[FromDecimal(decimal)](#FromDecimal_decimal)
- Converts a decimal under the Common Language Infrastructure (usually a.[FromDouble(double)](#FromDouble_double)
- Converts a 64-bit floating-point number to a rational number.[FromDoubleBits(long)](#FromDoubleBits_long)
- Creates a binary rational number from a 64-bit floating-point number encoded in the IEEE 754 binary64 format.[FromEDecimal(PeterO.Numbers.EDecimal)](#FromEDecimal_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal number to a rational number.[FromEFloat(PeterO.Numbers.EFloat)](#FromEFloat_PeterO_Numbers_EFloat)
- Converts an arbitrary-precision binary floating-point number to a rational number.[FromEInteger(PeterO.Numbers.EInteger)](#FromEInteger_PeterO_Numbers_EInteger)
- Converts an arbitrary-precision integer to a rational number.[FromExtendedDecimal(PeterO.Numbers.EDecimal)](#FromExtendedDecimal_PeterO_Numbers_EDecimal)
- Obsolete: Renamed to FromEDecimal.[FromExtendedFloat(PeterO.Numbers.EFloat)](#FromExtendedFloat_PeterO_Numbers_EFloat)
- Obsolete: Renamed to FromEFloat.[FromHalfBits(short)](#FromHalfBits_short)
- Creates a binary rational number from a binary floating-point number encoded in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number).[FromInt16(short)](#FromInt16_short)
- Converts a 16-bit signed integer to an arbitrary-precision rational number.[FromInt32(int)](#FromInt32_int)
- Converts a 32-bit signed integer to an arbitrary-precision rational number.[FromInt64(long)](#FromInt64_long)
- Converts a 64-bit signed integer to an arbitrary-precision rational number.[FromInt64AsUnsigned(long)](#FromInt64AsUnsigned_long)
- Converts an unsigned integer expressed as a 64-bit signed integer to an arbitrary-precision rational number.[FromSByte(sbyte)](#FromSByte_sbyte)
- Converts an 8-bit signed integer to an arbitrary-precision rational number.[FromSingle(float)](#FromSingle_float)
- Converts a 32-bit binary floating-point number to a rational number.[FromSingleBits(int)](#FromSingleBits_int)
- Creates a binary rational number from a 32-bit floating-point number encoded in the IEEE 754 binary32 format.[FromString(byte[])](#FromString_byte)
- Creates a rational number from a sequence of bytes that represents a number.[FromString(byte[], int, int)](#FromString_byte_int_int)
- Creates a rational number from a sequence of bytes that represents a number.[FromString(char[])](#FromString_char)
- Creates a rational number from a sequence of char s that represents a number.[FromString(char[], int, int)](#FromString_char_int_int)
- Creates a rational number from a sequence of char s that represents a number.[FromString(string)](#FromString_string)
- Creates a rational number from a text string that represents a number.[FromString(string, int, int)](#FromString_string_int_int)
- Creates a rational number from a text string that represents a number.[FromUInt16(ushort)](#FromUInt16_ushort)
- Converts a 16-bit unsigned integer to an arbitrary-precision rational number.[FromUInt32(uint)](#FromUInt32_uint)
- Converts a 32-bit signed integer to an arbitrary-precision rational number.[FromUInt64(ulong)](#FromUInt64_ulong)
- Converts a 64-bit unsigned integer to an arbitrary-precision rational number.[GetHashCode()](#GetHashCode)
- Returns the hash code for this instance.[implicit operator PeterO.Numbers.ERational(byte)](#implicit_operator_PeterO_Numbers_ERational_byte)
- Converts a byte (from 0 to 255) to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(decimal)](#implicit_operator_PeterO_Numbers_ERational_decimal)
- Converts a decimal under the Common Language Infrastructure (usually a.[implicit operator PeterO.Numbers.ERational(double)](#implicit_operator_PeterO_Numbers_ERational_double)
- Converts a 64-bit floating-point number to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(float)](#implicit_operator_PeterO_Numbers_ERational_float)
- Converts a 32-bit binary floating-point number to a rational number.[implicit operator PeterO.Numbers.ERational(int)](#implicit_operator_PeterO_Numbers_ERational_int)
- Converts a 32-bit signed integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(long)](#implicit_operator_PeterO_Numbers_ERational_long)
- Converts a 64-bit signed integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(PeterO.Numbers.EDecimal)](#implicit_operator_PeterO_Numbers_ERational_PeterO_Numbers_EDecimal)
- Converts an arbitrary-precision decimal floating-point number to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(PeterO.Numbers.EFloat)](#implicit_operator_PeterO_Numbers_ERational_PeterO_Numbers_EFloat)
- Converts an arbitrary-precision binary floating-point number to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(PeterO.Numbers.EInteger)](#implicit_operator_PeterO_Numbers_ERational_PeterO_Numbers_EInteger)
- Converts an arbitrary-precision integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(sbyte)](#implicit_operator_PeterO_Numbers_ERational_sbyte)
- Converts an 8-bit signed integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(short)](#implicit_operator_PeterO_Numbers_ERational_short)
- Converts a 16-bit signed integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(uint)](#implicit_operator_PeterO_Numbers_ERational_uint)
- Converts a 32-bit signed integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(ulong)](#implicit_operator_PeterO_Numbers_ERational_ulong)
- Converts a 64-bit unsigned integer to an arbitrary-precision rational number.[implicit operator PeterO.Numbers.ERational(ushort)](#implicit_operator_PeterO_Numbers_ERational_ushort)
- Converts a 16-bit unsigned integer to an arbitrary-precision rational number.[Increment()](#Increment)
- Adds one to an arbitrary-precision rational number.[IsFinite](#IsFinite)
- Gets a value indicating whether this object is finite (not infinity or NaN).[IsInfinity()](#IsInfinity)
- Gets a value indicating whether this object’s value is infinity.[IsInteger()](#IsInteger)
- Returns whether this object’s value is an integer.[IsNaN()](#IsNaN)
- Returns whether this object is a not-a-number value.[IsNegative](#IsNegative)
- Gets a value indicating whether this object’s value is negative (including negative zero).[IsNegativeInfinity()](#IsNegativeInfinity)
- Returns whether this object is negative infinity.[IsPositiveInfinity()](#IsPositiveInfinity)
- Returns whether this object is positive infinity.[IsQuietNaN()](#IsQuietNaN)
- Returns whether this object is a quiet not-a-number value.[IsSignalingNaN()](#IsSignalingNaN)
- Returns whether this object is a signaling not-a-number value (which causes an error if the value is passed to any arithmetic operation in this class).[IsZero](#IsZero)
- Gets a value indicating whether this object’s value equals 0.[Max(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#Max_PeterO_Numbers_ERational_PeterO_Numbers_ERational)
- Gets the greater value between two rational numbers.[MaxMagnitude(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#MaxMagnitude_PeterO_Numbers_ERational_PeterO_Numbers_ERational)
- Gets the greater value between two values, ignoring their signs.[Min(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#Min_PeterO_Numbers_ERational_PeterO_Numbers_ERational)
- Gets the lesser value between two rational numbers.[MinMagnitude(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#MinMagnitude_PeterO_Numbers_ERational_PeterO_Numbers_ERational)
- Gets the lesser value between two values, ignoring their signs.[Multiply(int)](#Multiply_int)
- Multiplies this arbitrary-precision rational number by a 32-bit signed integer and returns the result.[Multiply(long)](#Multiply_long)
- Multiplies this arbitrary-precision rational number by a 64-bit signed integer and returns the result.[Multiply(PeterO.Numbers.ERational)](#Multiply_PeterO_Numbers_ERational)
- Multiplies this arbitrary-precision rational number by another arbitrary-precision rational number and returns the result.[public static readonly PeterO.Numbers.ERational NaN;](#NaN)
- A not-a-number value.[Negate()](#Negate)
- Returns a rational number with the same value as this one but with the sign reversed.[public static readonly PeterO.Numbers.ERational NegativeInfinity;](#NegativeInfinity)
- Negative infinity, less than any other number.[public static readonly PeterO.Numbers.ERational NegativeZero;](#NegativeZero)
- A rational number for negative zero.[Numerator](#Numerator)
- Gets this object’s numerator.[public static readonly PeterO.Numbers.ERational One;](#One)
- The rational number one.[PeterO.Numbers.ERational operator +(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#op_Addition)
- Adds an arbitrary-precision rational number and another arbitrary-precision rational number and returns the result.[PeterO.Numbers.ERational operator --(PeterO.Numbers.ERational)](#op_Decrement)
- Subtracts one from an arbitrary-precision rational number.[PeterO.Numbers.ERational operator /(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#op_Division)
- Divides an arbitrary-precision rational number by the value of another arbitrary-precision rational number object.[PeterO.Numbers.ERational operator ++(PeterO.Numbers.ERational)](#op_Increment)
- Adds one to an arbitrary-precision rational number.[PeterO.Numbers.ERational operator %(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#op_Modulus)
- Returns the remainder that would result when an arbitrary-precision rational number is divided by another arbitrary-precision rational number.[PeterO.Numbers.ERational operator *(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#op_Multiply)
- Multiplies an arbitrary-precision rational number by another arbitrary-precision rational number and returns the result.[PeterO.Numbers.ERational operator -(PeterO.Numbers.ERational, PeterO.Numbers.ERational)](#op_Subtraction)
- Subtracts an arbitrary-precision rational number from this instance.[PeterO.Numbers.ERational operator -(PeterO.Numbers.ERational)](#op_UnaryNegation)
- Returns an arbitrary-precision rational number with the same value as the specified one but with its sign reversed.[public static readonly PeterO.Numbers.ERational PositiveInfinity;](#PositiveInfinity)
- Positive infinity, greater than any other number.[Remainder(int)](#Remainder_int)
- Returns the remainder that would result when this arbitrary-precision rational number is divided by a 32-bit signed integer.[Remainder(long)](#Remainder_long)
- Returns the remainder that would result when this arbitrary-precision rational number is divided by a 64-bit signed integer.[Remainder(PeterO.Numbers.ERational)](#Remainder_PeterO_Numbers_ERational)
- Returns the remainder that would result when this arbitrary-precision rational number is divided by another arbitrary-precision rational number.[Sign](#Sign)
- Gets the sign of this rational number.[public static readonly PeterO.Numbers.ERational SignalingNaN;](#SignalingNaN)
- A signaling not-a-number value.[Subtract(int)](#Subtract_int)
- Subtracts a 32-bit signed integer from this arbitrary-precision rational number and returns the result.[Subtract(long)](#Subtract_long)
- Subtracts a 64-bit signed integer from this arbitrary-precision rational number and returns the result.[Subtract(PeterO.Numbers.ERational)](#Subtract_PeterO_Numbers_ERational)
- Subtracts an arbitrary-precision rational number from this arbitrary-precision rational number and returns the result.[public static readonly PeterO.Numbers.ERational Ten;](#Ten)
- The rational number ten.[ToByteChecked()](#ToByteChecked)
- Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.[ToByteIfExact()](#ToByteIfExact)
- Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.[ToByteUnchecked()](#ToByteUnchecked)
- Converts this number’s value to an integer (using ToEInteger), and returns the least-significant bits of that integer’s two’s-complement form as a byte (from 0 to 255).[ToDecimal()](#ToDecimal)
- Converts this value to a decimal under the Common Language Infrastructure (usually a.[ToDouble()](#ToDouble)
- Converts this value to a 64-bit floating-point number.[ToDoubleBits()](#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.[ToEDecimal()](#ToEDecimal)
- Converts this rational number to an arbitrary-precision decimal number.[ToEDecimal(PeterO.Numbers.EContext)](#ToEDecimal_PeterO_Numbers_EContext)
- Converts this rational number to an arbitrary-precision decimal number and rounds the result to the specified precision.[ToEDecimalExactIfPossible(PeterO.Numbers.EContext)](#ToEDecimalExactIfPossible_PeterO_Numbers_EContext)
- Converts this rational number to an arbitrary-precision decimal number, but if the result would have a nonterminating decimal expansion, rounds that result to the specified precision.[ToEFloat()](#ToEFloat)
- Converts this rational number to a binary floating-point number.[ToEFloat(PeterO.Numbers.EContext)](#ToEFloat_PeterO_Numbers_EContext)
- Converts this rational number to a binary floating-point number and rounds that result to the specified precision.[ToEFloatExactIfPossible(PeterO.Numbers.EContext)](#ToEFloatExactIfPossible_PeterO_Numbers_EContext)
- Converts this rational number to a binary floating-point number, but if the result would have a nonterminating binary expansion, rounds that result to the specified precision.[ToEInteger()](#ToEInteger)
- Converts this value to an arbitrary-precision integer by dividing the numerator by the denominator and discarding the fractional part of the result.[ToEIntegerExact()](#ToEIntegerExact)
- Obsolete: Renamed to ToEIntegerIfExact.[ToEIntegerIfExact()](#ToEIntegerIfExact)
- Converts this value to an arbitrary-precision integer, checking whether the value is an exact integer.[ToExtendedDecimal()](#ToExtendedDecimal)
- Obsolete: Renamed to ToEDecimal.[ToExtendedDecimal(PeterO.Numbers.EContext)](#ToExtendedDecimal_PeterO_Numbers_EContext)
- Obsolete: Renamed to ToEDecimal.[ToExtendedDecimalExactIfPossible(PeterO.Numbers.EContext)](#ToExtendedDecimalExactIfPossible_PeterO_Numbers_EContext)
- Obsolete: Renamed to ToEDecimalExactIfPossible.[ToExtendedFloat()](#ToExtendedFloat)
- Obsolete: Renamed to ToEFloat.[ToExtendedFloat(PeterO.Numbers.EContext)](#ToExtendedFloat_PeterO_Numbers_EContext)
- Obsolete: Renamed to ToEFloat.[ToExtendedFloatExactIfPossible(PeterO.Numbers.EContext)](#ToExtendedFloatExactIfPossible_PeterO_Numbers_EContext)
- Obsolete: Renamed to ToEFloatExactIfPossible.[ToHalfBits()](#ToHalfBits)
- Converts this value to its closest equivalent as a binary floating-point number, expressed as an integer in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number).[ToInt16Checked()](#ToInt16Checked)
- Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.[ToInt16IfExact()](#ToInt16IfExact)
- Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer without rounding to a different numerical value.[ToInt16Unchecked()](#ToInt16Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit signed integer.[ToInt32Checked()](#ToInt32Checked)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[ToInt32IfExact()](#ToInt32IfExact)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.[ToInt32Unchecked()](#ToInt32Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.[ToInt64Checked()](#ToInt64Checked)
- Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.[ToInt64IfExact()](#ToInt64IfExact)
- Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer without rounding to a different numerical value.[ToInt64Unchecked()](#ToInt64Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit signed integer.[ToLowestTerms()](#ToLowestTerms)
- Converts this value to its form in lowest terms.[ToSByteChecked()](#ToSByteChecked)
- Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.[ToSByteIfExact()](#ToSByteIfExact)
- Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer without rounding to a different numerical value.[ToSByteUnchecked()](#ToSByteUnchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as an 8-bit signed integer.[ToSingle()](#ToSingle)
- Converts this value to a 32-bit binary floating-point number.[ToSingleBits()](#ToSingleBits)
- Converts this value to its closest equivalent as 32-bit floating-point number, expressed as an integer in the IEEE 754 binary32 format.[ToSizedEInteger(int)](#ToSizedEInteger_int)
- Converts this value to an arbitrary-precision integer by dividing the numerator by the denominator, discarding its fractional part, and checking whether the resulting integer overflows the specified signed bit count.[ToSizedEIntegerIfExact(int)](#ToSizedEIntegerIfExact_int)
- Converts this value to an arbitrary-precision integer, only if this number’s value is an exact integer and that integer does not overflow the specified signed bit count.[ToString()](#ToString)
- Converts this object to a text string.[ToUInt16Checked()](#ToUInt16Checked)
- Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.[ToUInt16IfExact()](#ToUInt16IfExact)
- Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer without rounding to a different numerical value.[ToUInt16Unchecked()](#ToUInt16Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit unsigned integer.[ToUInt32Checked()](#ToUInt32Checked)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.[ToUInt32IfExact()](#ToUInt32IfExact)
- Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.[ToUInt32Unchecked()](#ToUInt32Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.[ToUInt64Checked()](#ToUInt64Checked)
- Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.[ToUInt64IfExact()](#ToUInt64IfExact)
- Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer without rounding to a different numerical value.[ToUInt64Unchecked()](#ToUInt64Unchecked)
- Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit unsigned integer.[UnsignedNumerator](#UnsignedNumerator)
- Gets this object’s numerator with the sign removed.[public static readonly PeterO.Numbers.ERational Zero;](#Zero)
- A rational number for zero.
public ERational( PeterO.Numbers.EInteger numerator, PeterO.Numbers.EInteger denominator);
Obsolete. Use the Create method instead.
Initializes a new instance of the PeterO.Numbers.ERational class.
Parameters:
-
numerator: An arbitrary-precision integer serving as the numerator.
-
denominator: An arbitrary-precision integer serving as the denominator.
Exceptions:
-
System.ArgumentNullException: The parameter numerator or denominator is null.
-
System.ArgumentException: Denominator is zero.
public static readonly PeterO.Numbers.ERational NaN;
A not-a-number value.
public static readonly PeterO.Numbers.ERational NegativeInfinity;
Negative infinity, less than any other number.
public static readonly PeterO.Numbers.ERational NegativeZero;
A rational number for negative zero.
public static readonly PeterO.Numbers.ERational One;
The rational number one.
public static readonly PeterO.Numbers.ERational PositiveInfinity;
Positive infinity, greater than any other number.
public static readonly PeterO.Numbers.ERational SignalingNaN;
A signaling not-a-number value.
public static readonly PeterO.Numbers.ERational Ten;
The rational number ten.
public static readonly PeterO.Numbers.ERational Zero;
A rational number for zero.
public PeterO.Numbers.EInteger Denominator { get; }
Gets this object’s denominator.
Returns:
This object’s denominator.
public bool IsFinite { get; }
Gets a value indicating whether this object is finite (not infinity or NaN).
Returns:
true
if this object is finite (not infinity or NaN); otherwise, false
.
public bool IsNegative { get; }
Gets a value indicating whether this object’s value is negative (including negative zero).
Returns:
true
if this object’s value is negative (including negative zero); otherwise, false
. true
if this object’s value is negative; otherwise, false
.
public bool IsZero { get; }
Gets a value indicating whether this object’s value equals 0.
Returns:
true
if this object’s value equals 0; otherwise, false
. true
if this object’s value equals 0; otherwise, false
.
public PeterO.Numbers.EInteger Numerator { get; }
Gets this object’s numerator.
Returns:
This object’s numerator. If this object is a not-a-number value, returns the diagnostic information (which will be negative if this object is negative).
public int Sign { get; }
Gets the sign of this rational number.
Returns:
The sign of this rational number.
public PeterO.Numbers.EInteger UnsignedNumerator { get; }
Gets this object’s numerator with the sign removed.
Returns:
This object’s numerator. If this object is a not-a-number value, returns the diagnostic information.
public PeterO.Numbers.ERational Abs();
Returns the absolute value of this rational number, that is, a number with the same value as this one but as a nonnegative number.
Return Value:
An arbitrary-precision rational number.
public PeterO.Numbers.ERational Add( int v);
Adds this arbitrary-precision rational number and a 32-bit signed integer and returns the result.
Parameters:
- v: A 32-bit signed integer.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision rational number plus a 32-bit signed integer.
public PeterO.Numbers.ERational Add( long v);
Adds this arbitrary-precision rational number and a 64-bit signed integer and returns the result.
Parameters:
- v: A 64-bit signed integer.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision rational number plus a 64-bit signed integer.
public PeterO.Numbers.ERational Add( PeterO.Numbers.ERational otherValue);
Adds this arbitrary-precision rational number and another arbitrary-precision rational number and returns the result.
Parameters:
- otherValue: Another arbitrary-precision rational number.
Return Value:
The sum of the two numbers, that is, this arbitrary-precision rational number plus another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public int CompareTo( int intOther);
Compares the mathematical value of an arbitrary-precision rational number with that of this instance. This method currently uses the rules given in the CompareToValue method, so that it it is not consistent with the Equals method, but it may change in a future version to use the rules for the CompareToTotal method instead.
Parameters:
- intOther: The parameter intOther is a 32-bit signed integer.
Return Value:
Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater.
public int CompareTo( long intOther);
Compares the mathematical values of this object and another object, accepting NaN values. This method currently uses the rules given in the CompareToValue method, so that it it is not consistent with the Equals method, but it may change in a future version to use the rules for the CompareToTotal method instead.
Parameters:
- intOther: The parameter intOther is a 64-bit signed integer.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value, or 0 if both values are equal.
public sealed int CompareTo( PeterO.Numbers.ERational other);
Compares the mathematical value of an arbitrary-precision rational number with that of this instance. This method currently uses the rules given in the CompareToValue method, so that it it is not consistent with the Equals method, but it may change in a future version to use the rules for the CompareToTotal method instead.
Parameters:
- other: An arbitrary-precision rational number.
Return Value:
Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToBinary( PeterO.Numbers.EFloat other);
Compares an arbitrary-precision binary floating-point number with this instance. In this method, NaN values are greater than any other ERational or EFloat value, and two NaN values (even if their payloads differ) are treated as equal by this method.
Parameters:
- other: An arbitrary-precision binary floating-point number.
Return Value:
Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToDecimal( PeterO.Numbers.EDecimal other);
Compares an arbitrary-precision decimal number with this instance.
Parameters:
- other: An arbitrary-precision decimal number.
Return Value:
Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToTotal( PeterO.Numbers.ERational other);
Compares the values of this object and another object, imposing a total ordering on all possible values. In this method:
-
For objects with the same value, the one with the higher denominator has a greater “absolute value”.
-
Negative zero is less than positive zero.
-
Quiet NaN has a higher “absolute value” than signaling NaN. If both objects are quiet NaN or both are signaling NaN, the one with the higher diagnostic information has a greater “absolute value”.
-
NaN has a higher “absolute value” than infinity.
-
Infinity has a higher “absolute value” than any finite number.
-
Negative numbers are less than positive numbers.
Parameters:
- other: An arbitrary-precision rational number to compare with this one.
Return Value:
The number 0 if both objects have the same value, or -1 if this object is less than the other value, or 1 if this object is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToTotalMagnitude( PeterO.Numbers.ERational other);
Compares the absolute values of this object and another object, imposing a total ordering on all possible values (ignoring their signs). In this method:
-
For objects with the same value, the one with the higher denominator has a greater “absolute value”.
-
Negative zero and positive zero are considered equal.
-
Quiet NaN has a higher “absolute value” than signaling NaN. If both objects are quiet NaN or both are signaling NaN, the one with the higher diagnostic information has a greater “absolute value”.
-
NaN has a higher “absolute value” than infinity.
-
Infinity has a higher “absolute value” than any finite number.
Parameters:
- other: An arbitrary-precision rational number to compare with this one.
Return Value:
The number 0 if both objects have the same value, or -1 if this object is less than the other value, or 1 if this object is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public int CompareToValue( int intOther);
Compares the mathematical value of an arbitrary-precision rational number with that of this instance. In this method, NaN values are greater than any other ERational value, and two NaN values (even if their payloads differ) are treated as equal by this method. This method is not consistent with the Equals method.
Parameters:
- intOther: The parameter intOther is a 32-bit signed integer.
Return Value:
Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater.
public int CompareToValue( long intOther);
Compares the mathematical values of this object and another object, accepting NaN values. This method is not consistent with the Equals method because two different numbers with the same mathematical value, but different exponents, will compare as equal.
In this method, negative zero and positive zero are considered equal.
If this object is a quiet NaN or signaling NaN, this method will not trigger an error. Instead, NaN will compare greater than any other number, including infinity.
Parameters:
- intOther: The parameter intOther is a 64-bit signed integer.
Return Value:
Less than 0 if this object’s value is less than the other value, or greater than 0 if this object’s value is greater than the other value, or 0 if both values are equal.
public int CompareToValue( PeterO.Numbers.ERational other);
Compares the mathematical value of an arbitrary-precision rational number with that of this instance. In this method, NaN values are greater than any other ERational value, and two NaN values (even if their payloads differ) are treated as equal by this method. This method is not consistent with the Equals method.
Parameters:
- other: An arbitrary-precision rational number.
Return Value:
Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater. This implementation returns a positive number if other
is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.compareTo()
in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.
.
public PeterO.Numbers.ERational Copy();
Creates a copy of this arbitrary-precision rational number.
Return Value:
An arbitrary-precision rational number.
public PeterO.Numbers.ERational CopySign( PeterO.Numbers.ERational other);
Returns a number with the same value as this one, but copying the sign (positive or negative) of another number.
Parameters:
- other: A number whose sign will be copied.
Return Value:
An arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter other is null.
public static PeterO.Numbers.ERational Create( int numeratorSmall, int denominatorSmall);
Creates a rational number with the specified numerator and denominator.
Parameters:
-
numeratorSmall: The numerator.
-
denominatorSmall: The denominator.
Return Value:
An arbitrary-precision rational number.
Exceptions:
- System.ArgumentException: The denominator is zero.
public static PeterO.Numbers.ERational Create( long numeratorLong, long denominatorLong);
Creates a rational number with the specified numerator and denominator.
Parameters:
-
numeratorLong: The numerator.
-
denominatorLong: The denominator.
Return Value:
An arbitrary-precision rational number.
Exceptions:
- System.ArgumentException: The denominator is zero.
public static PeterO.Numbers.ERational Create( PeterO.Numbers.EInteger numerator, PeterO.Numbers.EInteger denominator);
Creates a rational number with the specified numerator and denominator.
Parameters:
-
numerator: The numerator.
-
denominator: The denominator.
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.ArgumentException: The denominator is zero.
-
System.ArgumentNullException: The parameter numerator or denominator is null.
public static PeterO.Numbers.ERational CreateNaN( PeterO.Numbers.EInteger diag, bool signaling, bool negative);
Creates a not-a-number arbitrary-precision rational number.
Parameters:
-
diag: An integer, 0 or greater, to use as diagnostic information associated with this object. If none is needed, should be zero. To get the diagnostic information from another arbitrary-precision rational number, use that object’s
UnsignedNumerator
property. -
signaling: Whether the return value will be signaling (true) or quiet (false).
-
negative: Whether the return value is negative.
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.ArgumentException: The parameter diag is less than 0.
-
System.ArgumentNullException: The parameter diag is null.
public static PeterO.Numbers.ERational CreateNaN( PeterO.Numbers.EInteger diag);
Creates a not-a-number arbitrary-precision rational number.
Parameters:
- diag: An integer, 0 or greater, to use as diagnostic information associated with this object. If none is needed, should be zero. To get the diagnostic information from another arbitrary-precision rational number, use that object’s
UnsignedNumerator
property.
Return Value:
An arbitrary-precision rational number.
Exceptions:
- System.ArgumentException: The parameter diag is less than 0.
public PeterO.Numbers.ERational Decrement();
Subtracts one from an arbitrary-precision rational number.
Return Value:
The given arbitrary-precision rational number minus one.
public PeterO.Numbers.ERational Divide( int v);
Divides this arbitrary-precision rational number by a 32-bit signed integer and returns the result.
Parameters:
- v: The parameter v is a 32-bit signed integer.
Return Value:
The result of dividing this arbitrary-precision rational number by a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: The parameter v is zero.
public PeterO.Numbers.ERational Divide( long v);
Divides this arbitrary-precision rational number by a 64-bit signed integer and returns the result.
Parameters:
- v: The parameter v is a 64-bit signed integer.
Return Value:
The result of dividing this arbitrary-precision rational number by a 64-bit signed integer.
Exceptions:
- System.ArithmeticException: The parameter v is zero.
public PeterO.Numbers.ERational Divide( PeterO.Numbers.ERational otherValue);
Divides this arbitrary-precision rational number by another arbitrary-precision rational number and returns the result.
Parameters:
- otherValue: An arbitrary-precision rational number.
Return Value:
The result of dividing this arbitrary-precision rational number by another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public override bool Equals( object obj);
Determines whether this object’s numerator, denominator, and properties are equal to those of another object and that other object is an arbitrary-precision rational number. Not-a-number values are considered equal if the rest of their properties are equal. This is not the same as value equality. Notably, two ERationals with the same value, but of which one is in lowest terms and the other is not, are compared as unequal by this method (example: 1/2 vs. 5/10).
Parameters:
- obj: The parameter obj is an arbitrary object.
Return Value:
true
if the objects are equal; otherwise, false
. In this method, two objects are not equal if they don’t have the same type or if one is null and the other isn’t.
public sealed bool Equals( PeterO.Numbers.ERational other);
Determines whether this object’s numerator, denominator, and properties are equal to those of another object. Not-a-number values are considered equal if the rest of their properties are equal.
Parameters:
- other: An arbitrary-precision rational number to compare to.
Return Value:
Either true
or false
.
public static PeterO.Numbers.ERational FromBoolean( bool boolValue);
Converts a Boolean value (true or false) to an arbitrary-precision rational number.
Parameters:
- boolValue: Either true or false.
Return Value:
The number 1 if boolValue is true; otherwise, 0.
public static PeterO.Numbers.ERational FromByte( byte inputByte);
Converts a byte (from 0 to 255) to an arbitrary-precision rational number.
Parameters:
- inputByte: The number to convert as a byte (from 0 to 255).
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromDecimal( decimal eint);
Converts a decimal
under the Common Language Infrastructure (usually a.NET Framework decimal) to a rational number.
Parameters:
- eint: The number to convert as a
decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
Return Value:
An arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromDouble( double flt);
Converts a 64-bit floating-point number to a rational number. This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the number to a string. 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, ERational.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:
- flt: The parameter flt is a 64-bit floating-point number.
Return Value:
A rational number with the same value as flt .
public static PeterO.Numbers.ERational FromDoubleBits( long value);
Creates a binary rational 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 number to a string.
Parameters:
- value: A 64-bit integer encoded in the IEEE 754 binary64 format.
Return Value:
A rational number with the same floating-point value as value .
public static PeterO.Numbers.ERational FromEDecimal( PeterO.Numbers.EDecimal ef);
Converts an arbitrary-precision decimal number to a rational number.
Parameters:
- ef: The number to convert as an arbitrary-precision decimal number.
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.ArgumentNullException: The parameter ef is null.
-
System.ArgumentException: doesn’t satisfy den.Sign >= 0.
public static PeterO.Numbers.ERational FromEFloat( PeterO.Numbers.EFloat ef);
Converts an arbitrary-precision binary floating-point number to a rational number.
Parameters:
- ef: The number to convert as an arbitrary-precision binary floating-point number.
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.ArgumentNullException: The parameter ef is null.
-
System.ArgumentException: doesn’t satisfy den.Sign >= 0.
public static PeterO.Numbers.ERational FromEInteger( PeterO.Numbers.EInteger bigint);
Converts an arbitrary-precision integer to a rational number.
Parameters:
- bigint: The number to convert as an arbitrary-precision integer.
Return Value:
The exact value of the integer as a rational number.
public static PeterO.Numbers.ERational FromExtendedDecimal( PeterO.Numbers.EDecimal ef);
Obsolete. Renamed to FromEDecimal.
Converts an arbitrary-precision decimal number to a rational number.
Parameters:
- ef: The number to convert as an arbitrary-precision decimal number.
Return Value:
An arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromExtendedFloat( PeterO.Numbers.EFloat ef);
Obsolete. Renamed to FromEFloat.
Converts an arbitrary-precision binary floating-point number to a rational number.
Parameters:
- ef: The number to convert as an arbitrary-precision binary floating-point number.
Return Value:
An arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromHalfBits( short value);
Creates a binary rational 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 number to a string.
Parameters:
- value: A 16-bit integer encoded in the IEEE 754 binary16 format.
Return Value:
A rational number with the same floating-point value as value .
public static PeterO.Numbers.ERational FromInt16( short inputInt16);
Converts a 16-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputInt16: The number to convert as a 16-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromInt32( int inputInt32);
Converts a 32-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputInt32: The number to convert as a 32-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromInt64( long inputInt64);
Converts a 64-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputInt64: The number to convert as a 64-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromInt64AsUnsigned( long longerValue);
Converts an unsigned integer expressed as a 64-bit signed integer to an arbitrary-precision rational number.
Parameters:
- longerValue: A 64-bit signed integer. If this value is 0 or greater, the return value will represent it. If this value is less than 0, the return value will store 2^64 plus this value instead.
Return Value:
An arbitrary-precision rational number. If longerValue is 0 or greater, the return value will represent it. If longerValue is less than 0, the return value will store 2^64 plus this value instead.
public static PeterO.Numbers.ERational FromSByte( sbyte inputSByte);
This API is not CLS-compliant.
Converts an 8-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputSByte: The number to convert as an 8-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromSingle( float flt);
Converts a 32-bit binary floating-point number to a rational number. This method computes the exact value of the floating point number, not an approximation, as is often the case by converting the number to a string. 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, ERational.FromSingle(Single.NaN)
or ERational.FromSingle(Float.NaN)
could produce an object that is represented differently between DotNet and Java, because Single.NaN
/ Float.NaN
may have a different form in DotNet and Java (for example, the NaN value’s sign may be negative in DotNet, but positive in Java). Use IsNaN()
to determine whether an object from this class stores a NaN value of any form.
Parameters:
- flt: The parameter flt is a 32-bit binary floating-point number.
Return Value:
A rational number with the same value as flt .
public static PeterO.Numbers.ERational FromSingleBits( int value);
Creates a binary rational 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 number to a string.
Parameters:
- value: A 32-bit integer encoded in the IEEE 754 binary32 format.
Return Value:
A rational number with the same floating-point value as value .
public static PeterO.Numbers.ERational FromString( byte[] bytes, int offset, int length);
Creates a rational number from a sequence of bytes that represents a number.
The format of the sequence of bytes generally consists of:
-
An optional plus sign (“+” , U+002B) or minus sign (“-“, U+002D) (if ‘-‘ , the value is negative.)
-
The numerator in the form of one or more digits (these digits may begin with any number of zeros).
-
Optionally, “/” followed by the denominator in the form of one or more digits (these digits may begin with any number of zeros). If a denominator is not given, it’s equal to 1.
The sequence of bytes can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN” /”-NaN”) followed by any number of digits, or signaling NaN (“sNaN” /”-sNaN”) followed by any number of digits, all in any combination of uppercase and lowercase.
All characters mentioned earlier are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U+0030 to U+0039). The sequence of bytes is not allowed to contain white space characters, including spaces.
Parameters:
-
bytes: A sequence of bytes, a portion of which represents a number.
-
offset: An index starting at 0 showing where the desired portion of bytes begins.
-
length: The length, in code units, of the desired portion of bytes (but not more than bytes ‘s length).
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.FormatException: The parameter bytes is not a correctly formatted sequence of bytes.
-
System.ArgumentNullException: The parameter bytes is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than bytes ‘s length, or bytes ‘s length minus offset is less than length .
public static PeterO.Numbers.ERational FromString( byte[] bytes);
Creates a rational number from a sequence of bytes that represents a number. See FromString(String, int, int)
for more information.
Parameters:
- bytes: A sequence of bytes that represents a number.
Return Value:
An arbitrary-precision rational number with the same value as the specified sequence of bytes.
Exceptions:
- System.FormatException: The parameter bytes is not a correctly formatted sequence of bytes.
public static PeterO.Numbers.ERational FromString( char[] chars, int offset, int length);
Creates a rational number from a sequence of char
s that represents a number.
The format of the sequence of char
s generally consists of:
-
An optional plus sign (“+” , U+002B) or minus sign (“-“, U+002D) (if ‘-‘ , the value is negative.)
-
The numerator in the form of one or more digits (these digits may begin with any number of zeros).
-
Optionally, “/” followed by the denominator in the form of one or more digits (these digits may begin with any number of zeros). If a denominator is not given, it’s equal to 1.
The sequence of char
s can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN” /”-NaN”) followed by any number of digits, or signaling NaN (“sNaN” /”-sNaN”) followed by any number of digits, all in any combination of uppercase and lowercase.
All characters mentioned earlier are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U+0030 to U+0039). The sequence of char
s is not allowed to contain white space characters, including spaces.
Parameters:
-
chars: A sequence of
char
s, a portion of which represents a number. -
offset: An index starting at 0 showing where the desired portion of chars begins.
-
length: The length, in code units, of the desired portion of chars (but not more than chars ‘s length).
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.FormatException: The parameter chars is not a correctly formatted sequence of
char
s. -
System.ArgumentNullException: The parameter chars is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than chars ‘s length, or chars ‘s length minus offset is less than length .
public static PeterO.Numbers.ERational FromString( char[] chars);
Creates a rational number from a sequence of char
s that represents a number. See FromString(String, int, int)
for more information.
Parameters:
- chars: A sequence of
char
s that represents a number.
Return Value:
An arbitrary-precision rational number with the same value as the specified sequence of char
s.
Exceptions:
- System.FormatException:
The parameter chars
is not a correctly formatted sequence of
char
s.
public static PeterO.Numbers.ERational FromString( string str, int offset, int length);
Creates a rational number from a text string that represents a number.
The format of the string generally consists of:
-
An optional plus sign (“+” , U+002B) or minus sign (“-“, U+002D) (if ‘-‘ , the value is negative.)
-
The numerator in the form of one or more digits (these digits may begin with any number of zeros).
-
Optionally, “/” followed by the denominator in the form of one or more digits (these digits may begin with any number of zeros). If a denominator is not given, it’s equal to 1.
The string can also be “-INF”, “-Infinity”, “Infinity”, “INF”, quiet NaN (“NaN” /”-NaN”) followed by any number of digits, or signaling NaN (“sNaN” /”-sNaN”) followed by any number of digits, all in any combination of uppercase and lowercase.
All characters mentioned earlier are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U+0030 to U+0039). The string is not allowed to contain white space characters, including spaces.
Parameters:
-
str: A text string, a portion of which represents a number.
-
offset: An index starting at 0 showing where the desired portion of str begins.
-
length: The length, in code units, of the desired portion of str (but not more than str ‘s length).
Return Value:
An arbitrary-precision rational number.
Exceptions:
-
System.FormatException: The parameter str is not a correctly formatted number string.
-
System.ArgumentNullException: The parameter str is null.
-
System.ArgumentException: Either offset or length is less than 0 or greater than str ‘s length, or str ‘s length minus offset is less than length .
public static PeterO.Numbers.ERational FromString( string str);
Creates a rational number from a text string that represents a number. See FromString(String, int, int)
for more information.
Parameters:
- str: A string that represents a number.
Return Value:
An arbitrary-precision rational number with the same value as the specified string.
Exceptions:
- System.FormatException: The parameter str is not a correctly formatted number string.
public static PeterO.Numbers.ERational FromUInt16( ushort inputUInt16);
This API is not CLS-compliant.
Converts a 16-bit unsigned integer to an arbitrary-precision rational number.
Parameters:
- inputUInt16: The number to convert as a 16-bit unsigned integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromUInt32( uint inputUInt32);
This API is not CLS-compliant.
Converts a 32-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputUInt32: The number to convert as a 32-bit signed integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational FromUInt64( ulong inputUInt64);
This API is not CLS-compliant.
Converts a 64-bit unsigned integer to an arbitrary-precision rational number.
Parameters:
- inputUInt64: The number to convert as a 64-bit unsigned integer.
Return Value:
This number’s value as an arbitrary-precision rational number.
public override int GetHashCode();
Returns the hash code for this instance. No application or process IDs are used in the hash code calculation.
Return Value:
A 32-bit signed integer.
public PeterO.Numbers.ERational Increment();
Adds one to an arbitrary-precision rational number.
Return Value:
The given arbitrary-precision rational number plus one.
public bool IsInfinity();
Gets a value indicating whether this object’s value is infinity.
Return Value:
true
if this object’s value is infinity; otherwise, false
.
public bool IsInteger();
Returns whether this object’s value is an integer.
Return Value:
true
if this object’s value is an integer; otherwise, false
.
public bool IsNaN();
Returns whether this object is a not-a-number value.
Return Value:
true
if this object is a not-a-number value; otherwise, false
.
public bool IsNegativeInfinity();
Returns whether this object is negative infinity.
Return Value:
true
if this object is negative infinity; otherwise, false
.
public bool IsPositiveInfinity();
Returns whether this object is positive infinity.
Return Value:
true
if this object is positive infinity; otherwise, false
.
public bool IsQuietNaN();
Returns whether this object is a quiet not-a-number value.
Return Value:
true
if this object is a quiet not-a-number value; otherwise, false
.
public bool IsSignalingNaN();
Returns whether this object is a signaling not-a-number value (which causes an error if the value is passed to any arithmetic operation in this class).
Return Value:
true
if this object is a signaling not-a-number value (which causes an error if the value is passed to any arithmetic operation in this class); otherwise, false
.
public static PeterO.Numbers.ERational Max( PeterO.Numbers.ERational first, PeterO.Numbers.ERational second);
Gets the greater value between two rational numbers.
Parameters:
-
first: An arbitrary-precision rational number.
-
second: Another arbitrary-precision rational number.
Return Value:
The larger value of the two numbers. If one is positive zero and the other is negative zero, returns the positive zero. If the two numbers are positive and have the same value, returns the one with the larger denominator. If the two numbers are negative and have the same value, returns the one with the smaller denominator.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.ERational MaxMagnitude( PeterO.Numbers.ERational first, PeterO.Numbers.ERational second);
Gets the greater value between two values, ignoring their signs. If the absolute values are equal, has the same effect as Max.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
Return Value:
The larger value of the two numbers, ignoring their signs.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.ERational Min( PeterO.Numbers.ERational first, PeterO.Numbers.ERational second);
Gets the lesser value between two rational numbers.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
Return Value:
The smaller value of the two numbers. If one is positive zero and the other is negative zero, returns the negative zero. If the two numbers are positive and have the same value, returns the one with the smaller denominator. If the two numbers are negative and have the same value, returns the one with the larger denominator.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public static PeterO.Numbers.ERational MinMagnitude( PeterO.Numbers.ERational first, PeterO.Numbers.ERational second);
Gets the lesser value between two values, ignoring their signs. If the absolute values are equal, has the same effect as Min.
Parameters:
-
first: The first value to compare.
-
second: The second value to compare.
Return Value:
The smaller value of the two numbers, ignoring their signs.
Exceptions:
- System.ArgumentNullException: The parameter first or second is null.
public PeterO.Numbers.ERational Multiply( int v);
Multiplies this arbitrary-precision rational number by a 32-bit signed integer and returns the result.
Parameters:
- v: The parameter v is a 32-bit signed integer.
Return Value:
The product of the two numbers, that is, this arbitrary-precision rational number times a 32-bit signed integer.
public PeterO.Numbers.ERational Multiply( long v);
Multiplies this arbitrary-precision rational number by a 64-bit signed integer and returns the result.
Parameters:
- v: The parameter v is a 64-bit signed integer.
Return Value:
The product of the two numbers, that is, this arbitrary-precision rational number times a 64-bit signed integer.
public PeterO.Numbers.ERational Multiply( PeterO.Numbers.ERational otherValue);
Multiplies this arbitrary-precision rational number by another arbitrary-precision rational number and returns the result.
Parameters:
- otherValue: An arbitrary-precision rational number.
Return Value:
The product of the two numbers, that is, this arbitrary-precision rational number times another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public PeterO.Numbers.ERational Negate();
Returns a rational number with the same value as this one but with the sign reversed.
Return Value:
An arbitrary-precision rational number.
public static PeterO.Numbers.ERational operator +( PeterO.Numbers.ERational bthis, PeterO.Numbers.ERational augend);
Adds an arbitrary-precision rational number and another arbitrary-precision rational number and returns the result.
Parameters:
-
bthis: The first operand.
-
augend: The second operand.
Return Value:
The sum of the two numbers, that is, an arbitrary-precision rational number plus another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter “otherValue” is null.
public static PeterO.Numbers.ERational operator --( PeterO.Numbers.ERational bthis);
Subtracts one from an arbitrary-precision rational number.
Parameters:
- bthis: An arbitrary-precision rational number.
Return Value:
The number given in bthis minus one.
Exceptions:
- System.ArgumentNullException: The parameter bthis is null.
public static PeterO.Numbers.ERational operator /( PeterO.Numbers.ERational dividend, PeterO.Numbers.ERational divisor);
Divides an arbitrary-precision rational number by the value of another arbitrary-precision rational number object.
Parameters:
-
dividend: An arbitrary-precision rational number serving as the dividend.
-
divisor: An arbitrary-precision rational number serving as the divisor.
Return Value:
The quotient of the two objects.
Exceptions:
- System.ArgumentNullException: The parameter “otherValue” is null.
public static explicit operator byte( PeterO.Numbers.ERational input);
Converts an arbitrary-precision rational number to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a byte (from 0 to 255).
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 255.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator decimal( PeterO.Numbers.ERational extendedNumber);
Converts an arbitrary-precision rational number to a decimal
under the Common Language Infrastructure (see "Forms of numbers"“Forms of numbers” ).
Parameters:
- extendedNumber: The number to convert as an arbitrary-precision rational number.
Return Value:
A decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
Exceptions:
- System.ArgumentNullException: The parameter extendedNumber is null.
public static explicit operator double( PeterO.Numbers.ERational bigValue);
Converts an arbitrary-precision rational number to a 64-bit floating-point number. The half-even rounding mode is used.
Parameters:
- bigValue: The number to convert as an arbitrary-precision rational number.
Return Value:
The closest 64-bit floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 64-bit floating point number.
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator float( PeterO.Numbers.ERational bigValue);
Converts an arbitrary-precision rational number to a 32-bit binary floating-point number. The half-even rounding mode is used.
Parameters:
- bigValue: The number to convert as an arbitrary-precision rational number.
Return Value:
The closest 32-bit binary floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 32-bit floating point number.
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator int( PeterO.Numbers.ERational input);
Converts an arbitrary-precision rational number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a 32-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -2147483648 or greater than 2147483647.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator long( PeterO.Numbers.ERational input);
Converts an arbitrary-precision rational number to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a 64-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -9223372036854775808 or greater than 9223372036854775807.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator PeterO.Numbers.EInteger( PeterO.Numbers.ERational bigValue);
Converts an arbitrary-precision rational number to an arbitrary-precision integer. Any fractional part in the value will be discarded when converting to an arbitrary-precision integer.
Parameters:
- bigValue: An arbitrary-precision rational number.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN).
-
System.ArgumentNullException: The parameter bigValue is null.
public static explicit operator PeterO.Numbers.ERational( bool boolValue);
Converts a Boolean value (true or false) to an arbitrary-precision rational number.
Parameters:
- boolValue: Either true or false.
Return Value:
1 if boolValue is true; otherwise, 0.
public static explicit operator sbyte( PeterO.Numbers.ERational input);
This API is not CLS-compliant.
Converts an arbitrary-precision rational number to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to an 8-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -128 or greater than 127.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator short( PeterO.Numbers.ERational input);
Converts an arbitrary-precision rational number to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a 16-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -32768 or greater than 32767.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator uint( PeterO.Numbers.ERational input);
This API is not CLS-compliant.
Converts an arbitrary-precision rational number to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a 32-bit signed integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 4294967295.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator ulong( PeterO.Numbers.ERational input);
This API is not CLS-compliant.
Converts an arbitrary-precision rational number to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a 64-bit unsigned integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 18446744073709551615.
-
System.ArgumentNullException: The parameter input is null.
public static explicit operator ushort( PeterO.Numbers.ERational input);
This API is not CLS-compliant.
Converts an arbitrary-precision rational number to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.
Parameters:
- input: The number to convert as an arbitrary-precision rational number.
Return Value:
The value of input , truncated to a 16-bit unsigned integer.
Exceptions:
-
System.OverflowException: The parameter input is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 65535.
-
System.ArgumentNullException: The parameter input is null.
public static implicit operator PeterO.Numbers.ERational( byte inputByte);
Converts a byte (from 0 to 255) to an arbitrary-precision rational number.
Parameters:
- inputByte: The number to convert as a byte (from 0 to 255).
Return Value:
The value of inputByte as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( decimal eint);
Converts a decimal
under the Common Language Infrastructure (usually a.NET Framework decimal). to an arbitrary-precision rational number.
Parameters:
- eint: A
decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
Return Value:
An arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( double eint);
Converts a 64-bit floating-point number to an arbitrary-precision rational number.
Parameters:
- eint: The parameter eint is a 64-bit floating-point number.
Return Value:
An arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( float eint);
Converts a 32-bit binary floating-point number to a rational number.
Parameters:
- eint: The parameter eint is a 32-bit binary floating-point number.
Return Value:
The value of eint as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( int inputInt32);
Converts a 32-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputInt32: The number to convert as a 32-bit signed integer.
Return Value:
The value of inputInt32 as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( long inputInt64);
Converts a 64-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputInt64: The number to convert as a 64-bit signed integer.
Return Value:
The value of inputInt64 as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( PeterO.Numbers.EDecimal eint);
Converts an arbitrary-precision decimal floating-point number to an arbitrary-precision rational number.
Parameters:
- eint: The parameter eint is an arbitrary-precision decimal floating-point number.
Return Value:
An arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( PeterO.Numbers.EFloat eint);
Converts an arbitrary-precision binary floating-point number to an arbitrary-precision rational number.
Parameters:
- eint: An arbitrary-precision binary floating-point number.
Return Value:
An arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( PeterO.Numbers.EInteger eint);
Converts an arbitrary-precision integer to an arbitrary-precision rational number.
Parameters:
- eint: An arbitrary-precision integer.
Return Value:
An arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( sbyte inputSByte);
This API is not CLS-compliant.
Converts an 8-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputSByte: The number to convert as an 8-bit signed integer.
Return Value:
The value of inputSByte as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( short inputInt16);
Converts a 16-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputInt16: The number to convert as a 16-bit signed integer.
Return Value:
The value of inputInt16 as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( uint inputUInt32);
This API is not CLS-compliant.
Converts a 32-bit signed integer to an arbitrary-precision rational number.
Parameters:
- inputUInt32: The number to convert as a 32-bit signed integer.
Return Value:
The value of inputUInt32 as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( ulong inputUInt64);
This API is not CLS-compliant.
Converts a 64-bit unsigned integer to an arbitrary-precision rational number.
Parameters:
- inputUInt64: The number to convert as a 64-bit unsigned integer.
Return Value:
The value of inputUInt64 as an arbitrary-precision rational number.
public static implicit operator PeterO.Numbers.ERational( ushort inputUInt16);
This API is not CLS-compliant.
Converts a 16-bit unsigned integer to an arbitrary-precision rational number.
Parameters:
- inputUInt16: The number to convert as a 16-bit unsigned integer.
Return Value:
The value of inputUInt16 as an arbitrary-precision rational number.
public static PeterO.Numbers.ERational operator ++( PeterO.Numbers.ERational bthis);
Adds one to an arbitrary-precision rational number.
Parameters:
- bthis: An arbitrary-precision rational number.
Return Value:
The number given in bthis plus one.
Exceptions:
- System.ArgumentNullException: The parameter bthis is null.
public static PeterO.Numbers.ERational operator %( PeterO.Numbers.ERational dividend, PeterO.Numbers.ERational divisor);
Returns the remainder that would result when an arbitrary-precision rational number is divided by another arbitrary-precision rational number.
Parameters:
-
dividend: The dividend.
-
divisor: The divisor.
Return Value:
The remainder that would result when an arbitrary-precision rational number is divided by another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter “otherValue” is null.
public static PeterO.Numbers.ERational operator *( PeterO.Numbers.ERational operand1, PeterO.Numbers.ERational operand2);
Multiplies an arbitrary-precision rational number by another arbitrary-precision rational number and returns the result.
Parameters:
-
operand1: The first operand.
-
operand2: The second operand.
Return Value:
The product of the two numbers, that is, an arbitrary-precision rational number times another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter “otherValue” is null.
public static PeterO.Numbers.ERational operator -( PeterO.Numbers.ERational bthis, PeterO.Numbers.ERational subtrahend);
Subtracts an arbitrary-precision rational number from this instance.
Parameters:
-
bthis: The first operand.
-
subtrahend: The second operand.
Return Value:
The difference of the two objects.
Exceptions:
- System.ArgumentNullException: The parameter “otherValue” is null.
public static PeterO.Numbers.ERational operator -( PeterO.Numbers.ERational bigValue);
Returns an arbitrary-precision rational number with the same value as the specified one but with its sign reversed.
Parameters:
- bigValue: An arbitrary-precision rational number to negate.
Return Value:
An arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter bigValue is null.
public PeterO.Numbers.ERational Remainder( int v);
Returns the remainder that would result when this arbitrary-precision rational number is divided by a 32-bit signed integer.
Parameters:
- v: The divisor.
Return Value:
The remainder that would result when this arbitrary-precision rational number is divided by a 32-bit signed integer.
Exceptions:
- System.ArgumentException: The parameter v is zero.
public PeterO.Numbers.ERational Remainder( long v);
Returns the remainder that would result when this arbitrary-precision rational number is divided by a 64-bit signed integer.
Parameters:
- v: The divisor.
Return Value:
The remainder that would result when this arbitrary-precision rational number is divided by a 64-bit signed integer.
Exceptions:
- System.ArgumentException: The parameter v is zero.
public PeterO.Numbers.ERational Remainder( PeterO.Numbers.ERational otherValue);
Returns the remainder that would result when this arbitrary-precision rational number is divided by another arbitrary-precision rational number.
Parameters:
- otherValue: An arbitrary-precision rational number.
Return Value:
The remainder that would result when this arbitrary-precision rational number is divided by another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public PeterO.Numbers.ERational Subtract( int v);
Subtracts a 32-bit signed integer from this arbitrary-precision rational number and returns the result.
Parameters:
- v: The parameter v is a 32-bit signed integer.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision rational number minus a 32-bit signed integer.
public PeterO.Numbers.ERational Subtract( long v);
Subtracts a 64-bit signed integer from this arbitrary-precision rational number and returns the result.
Parameters:
- v: The parameter v is a 64-bit signed integer.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision rational number minus a 64-bit signed integer.
public PeterO.Numbers.ERational Subtract( PeterO.Numbers.ERational otherValue);
Subtracts an arbitrary-precision rational number from this arbitrary-precision rational number and returns the result.
Parameters:
- otherValue: An arbitrary-precision rational number.
Return Value:
The difference between the two numbers, that is, this arbitrary-precision rational number minus another arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter otherValue is null.
public byte ToByteChecked();
Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a byte (from 0 to 255).
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 255.
public byte ToByteIfExact();
Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255) without rounding to a different numerical value.
Return Value:
This number’s value as a byte (from 0 to 255).
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 255.
public byte ToByteUnchecked();
Converts this number’s value to an integer (using ToEInteger), and returns the least-significant bits of that integer’s two’s-complement form as a byte (from 0 to 255).
Return Value:
This number, converted to a byte (from 0 to 255). Returns 0 if this value is infinity or not-a-number.
public decimal ToDecimal();
Converts this value to a decimal
under the Common Language Infrastructure (usually a.NET Framework decimal). Currently, converts this value to the precision and range of a.NET Framework decimal.
Return Value:
A decimal
under the Common Language Infrastructure (usually a.NET Framework decimal).
public double ToDouble();
Converts this value to a 64-bit floating-point number. The half-even rounding mode is used.
Return Value:
The closest 64-bit floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 64-bit floating point number.
public long ToDoubleBits();
Converts this value to its closest equivalent as a 64-bit floating-point number, 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.
public PeterO.Numbers.EDecimal ToEDecimal( PeterO.Numbers.EContext ctx);
Converts this rational number to an arbitrary-precision decimal number and rounds the result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The value of the rational number, rounded to the specified precision. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating decimal expansion.
public PeterO.Numbers.EDecimal ToEDecimal();
Converts this rational number to an arbitrary-precision decimal number.
Return Value:
The exact value of the rational number, or not-a-number (NaN) if the result can’t be exact because it has a nonterminating decimal expansion.
public PeterO.Numbers.EDecimal ToEDecimalExactIfPossible( PeterO.Numbers.EContext ctx);
Converts this rational number to an arbitrary-precision decimal number, but if the result would have a nonterminating decimal expansion, rounds that result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only if the exact result would have a nonterminating decimal expansion. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The exact value of the rational number if possible; otherwise, the rounded version of the result if a context is given. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating decimal expansion.
public PeterO.Numbers.EFloat ToEFloat( PeterO.Numbers.EContext ctx);
Converts this rational number to a binary floating-point number and rounds that result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The value of the rational number, rounded to the specified precision. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating binary expansion.
public PeterO.Numbers.EFloat ToEFloat();
Converts this rational number to a binary floating-point number.
Return Value:
The exact value of the rational number, or not-a-number (NaN) if the result can’t be exact because it has a nonterminating binary expansion.
public PeterO.Numbers.EFloat ToEFloatExactIfPossible( PeterO.Numbers.EContext ctx);
Converts this rational number to a binary floating-point number, but if the result would have a nonterminating binary expansion, rounds that result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only if the exact result would have a nonterminating binary expansion. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The exact value of the rational number if possible; otherwise, the rounded version of the result if a context is given. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating binary expansion.
public PeterO.Numbers.EInteger ToEInteger();
Converts this value to an arbitrary-precision integer by dividing the numerator by the denominator and discarding the fractional part of the result.
Return Value:
An arbitrary-precision integer.
Exceptions:
- System.OverflowException: This object’s value is infinity or not-a-number (NaN).
public PeterO.Numbers.EInteger ToEIntegerExact();
Obsolete. Renamed to ToEIntegerIfExact.
Converts this value to an arbitrary-precision integer, checking whether the value is an exact integer.
Return Value:
An arbitrary-precision integer.
Exceptions:
- System.OverflowException: This object’s value is infinity or not-a-number (NaN).
public PeterO.Numbers.EInteger ToEIntegerIfExact();
Converts this value to an arbitrary-precision integer, checking whether the value is an exact integer.
Return Value:
An arbitrary-precision integer.
Exceptions:
- System.OverflowException: This object’s value is infinity or not-a-number (NaN).
public PeterO.Numbers.EDecimal ToExtendedDecimal( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to ToEDecimal.
Converts this rational number to an arbitrary-precision decimal number and rounds the result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The value of the rational number, rounded to the specified precision. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating decimal expansion.
public PeterO.Numbers.EDecimal ToExtendedDecimal();
Obsolete. Renamed to ToEDecimal.
Converts this rational number to an arbitrary-precision decimal number.
Return Value:
The exact value of the rational number, or not-a-number (NaN) if the result can’t be exact because it has a nonterminating decimal expansion.
### ToExtendedDecimalExactIfPossible
public PeterO.Numbers.EDecimal ToExtendedDecimalExactIfPossible( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to ToEDecimalExactIfPossible.
Converts this rational number to an arbitrary-precision decimal number, but if the result would have a nonterminating decimal expansion, rounds that result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only if the exact result would have a nonterminating decimal expansion. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The exact value of the rational number if possible; otherwise, the rounded version of the result if a context is given. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating decimal expansion.
public PeterO.Numbers.EFloat ToExtendedFloat( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to ToEFloat.
Converts this rational number to a binary floating-point number and rounds that result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The value of the rational number, rounded to the specified precision. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating binary expansion.
public PeterO.Numbers.EFloat ToExtendedFloat();
Obsolete. Renamed to ToEFloat.
Converts this rational number to a binary floating-point number.
Return Value:
The exact value of the rational number, or not-a-number (NaN) if the result can’t be exact because it has a nonterminating binary expansion.
### ToExtendedFloatExactIfPossible
public PeterO.Numbers.EFloat ToExtendedFloatExactIfPossible( PeterO.Numbers.EContext ctx);
Obsolete. Renamed to ToEFloatExactIfPossible.
Converts this rational number to a binary floating-point number, but if the result would have a nonterminating binary expansion, rounds that result to the specified precision.
Parameters:
- ctx: An arithmetic context object to control the precision, rounding, and exponent range of the result. This context will be used only if the exact result would have a nonterminating binary expansion. If HasFlags of the context is true, will also store the flags resulting from the operation (the flags are in addition to the pre-existing flags). Can be null, in which case the precision is unlimited and no rounding is needed.
Return Value:
The exact value of the rational number if possible; otherwise, the rounded version of the result if a context is given. Returns not-a-number (NaN) if the context is null and the result can’t be exact because it has a nonterminating binary expansion.
public short ToHalfBits();
Converts this value to its closest equivalent as a binary floating-point number, expressed as an integer in the IEEE 754 binary16 format (also known as a “half-precision” floating-point number). The half-even rounding mode is used. If this value is a NaN, sets the high bit of the binary16 number’s significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object’s unsigned significand, and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN.
Return Value:
The closest binary floating-point number to this value, expressed as an integer in the IEEE 754 binary16 format. The return value can be positive infinity or negative infinity if this value exceeds the range of a floating-point number in the binary16 format.
public short ToInt16Checked();
Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 16-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -32768 or greater than 32767.
public short ToInt16IfExact();
Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 16-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -32768 or greater than 32767.
public short ToInt16Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit signed integer.
Return Value:
This number, converted to a 16-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public int ToInt32Checked();
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 32-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -2147483648 or greater than 2147483647.
public int ToInt32IfExact();
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -2147483648 or greater than 2147483647.
public int ToInt32Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.
Return Value:
This number, converted to a 32-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public long ToInt64Checked();
Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 64-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -9223372036854775808 or greater than 9223372036854775807.
public long ToInt64IfExact();
Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 64-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -9223372036854775808 or greater than 9223372036854775807.
public long ToInt64Unchecked();
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit signed integer.
Return Value:
This number, converted to a 64-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public PeterO.Numbers.ERational ToLowestTerms();
Converts this value to its form in lowest terms. For example, (8/4) becomes (4/1).
Return Value:
An arbitrary-precision rational with the same value as this one but in lowest terms. Returns this object if it is infinity or NaN. Returns ERational.NegativeZero if this object is a negative zero. Returns ERational.Zero if this object is a positive zero.
Exceptions:
- System.OverflowException: This object’s value is infinity or not-a-number (NaN).
public sbyte ToSByteChecked();
This API is not CLS-compliant.
Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to an 8-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than -128 or greater than 127.
public sbyte ToSByteIfExact();
This API is not CLS-compliant.
Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as an 8-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than -128 or greater than 127.
public sbyte ToSByteUnchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as an 8-bit signed integer.
Return Value:
This number, converted to an 8-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public float ToSingle();
Converts this value to a 32-bit binary floating-point number. The half-even rounding mode is used.
Return Value:
The closest 32-bit binary floating-point number to this value. The return value can be positive infinity or negative infinity if this value exceeds the range of a 32-bit floating point number.
public int ToSingleBits();
Converts this value to its closest equivalent as 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.
public PeterO.Numbers.EInteger ToSizedEInteger( int maxBitLength);
Converts this value to an arbitrary-precision integer by dividing the numerator by the denominator, discarding its fractional part, and checking whether the resulting integer overflows the specified signed bit count.
Parameters:
- maxBitLength: The maximum number of signed bits the integer can have. The integer’s value may not be less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
Return Value:
An arbitrary-precision integer.
Exceptions:
- System.OverflowException: This object’s value is infinity or not-a-number (NaN), or this number’s value, once converted to an integer by dividing the numerator by the denominator and discarding its fractional part, is less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
public PeterO.Numbers.EInteger ToSizedEIntegerIfExact( int maxBitLength);
Converts this value to an arbitrary-precision integer, only if this number’s value is an exact integer and that integer does not overflow the specified signed bit count.
Parameters:
- maxBitLength: The maximum number of signed bits the integer can have. The integer’s value may not be less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
Return Value:
An arbitrary-precision integer.
Exceptions:
-
System.OverflowException: This object’s value is infinity or not-a-number (NaN), or this number’s value as an integer is less than -(2^maxBitLength) or greater than (2^maxBitLength) - 1.
-
System.ArithmeticException: This object’s value is not an exact integer.
public override string ToString();
Converts this object to a text string.
Return Value:
A string representation of this object. If this object’s value is infinity or not-a-number, the result is the analogous return value of the EDecimal.ToString
method. Otherwise, the return value has the following form: [-]numerator/denominator
.
public ushort ToUInt16Checked();
This API is not CLS-compliant.
Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 16-bit unsigned integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 65535.
public ushort ToUInt16IfExact();
This API is not CLS-compliant.
Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer without rounding to a different numerical value.
Return Value:
This number’s value as a 16-bit unsigned integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 65535.
public ushort ToUInt16Unchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 16-bit unsigned integer.
Return Value:
This number, converted to a 16-bit unsigned integer. Returns 0 if this value is infinity or not-a-number.
public uint ToUInt32Checked();
This API is not CLS-compliant.
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 32-bit signed integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 4294967295.
public uint ToUInt32IfExact();
This API is not CLS-compliant.
Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer without rounding to a different numerical value.
Return Value:
This number’s value as a 32-bit signed integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 4294967295.
public uint ToUInt32Unchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 32-bit signed integer.
Return Value:
This number, converted to a 32-bit signed integer. Returns 0 if this value is infinity or not-a-number.
public ulong ToUInt64Checked();
This API is not CLS-compliant.
Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer after converting it to an integer by discarding its fractional part.
Return Value:
This number’s value, truncated to a 64-bit unsigned integer.
Exceptions:
- System.OverflowException: This value is infinity or not-a-number, or the number, once converted to an integer by discarding its fractional part, is less than 0 or greater than 18446744073709551615.
public ulong ToUInt64IfExact();
This API is not CLS-compliant.
Converts this number’s value to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer without rounding to a different numerical value.
Return Value:
This number’s value as a 64-bit unsigned integer.
Exceptions:
- System.ArithmeticException: This value is infinity or not-a-number, is not an exact integer, or is less than 0 or greater than 18446744073709551615.
public ulong ToUInt64Unchecked();
This API is not CLS-compliant.
Converts this number’s value to an integer by discarding its fractional part, and returns the least-significant bits of its two’s-complement form as a 64-bit unsigned integer.
Return Value:
This number, converted to a 64-bit unsigned integer. Returns 0 if this value is infinity or not-a-number.