PeterO.ExtendedRational
PeterO.ExtendedRational
public sealed class ExtendedRational : System.IEquatable, System.IComparable
Deprecated. Use ERational from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.
This class is largely obsolete. It will be replaced by a new version of this class in a different namespace/package and library, called PeterO.Numbers.ERational
in the PeterO.Numbers
library (in .NET), or com.upokecenter.numbers.ERational
in the com.github.peteroupc/numbers
artifact (in Java). This new class can be used in the CBORObject.FromObject(object)
method (by including the new library in your code, among other things).
Arbitrary-precision rational number. This class can't be inherited; this is a change in version 2.0 from previous versions, where the class was inadvertently left inheritable. 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
CompareTo(PeterO.ExtendedRational)
- Compares this value to another.Create(int, int)
- Creates a rational number with the given numerator and denominator.Create(PeterO.BigInteger, PeterO.BigInteger)
- Creates a rational number with the given numerator and denominator.Denominator
- Gets this object's denominator.Equals(object)
- Checks whether this and another value are equal.Equals(PeterO.ExtendedRational)
- Checks whether this and another value are equal.GetHashCode()
- Calculates the hash code for this object.IsFinite
- Gets a value indicating whether this object is finite (not infinity or NaN).IsNegative
- Gets a value indicating whether this object's value is negative (including negative zero).IsZero
- Gets a value indicating whether this object's value equals 0.public static readonly PeterO.ExtendedRational NaN;
- A not-a-number value.public static readonly PeterO.ExtendedRational NegativeInfinity;
- Negative infinity, less than any other number.public static readonly PeterO.ExtendedRational NegativeZero;
- A rational number for negative zero.Numerator
- Gets this object's numerator.public static readonly PeterO.ExtendedRational One;
- The rational number one.public static readonly PeterO.ExtendedRational PositiveInfinity;
- Positive infinity, greater than any other number.Sign
- Gets the sign of this rational number.public static readonly PeterO.ExtendedRational SignalingNaN;
- A signaling not-a-number value.public static readonly PeterO.ExtendedRational Ten;
- The rational number ten.ToString()
- Converts this object to a text string.UnsignedNumerator
- Gets this object's numerator with the sign removed.public static readonly PeterO.ExtendedRational Zero;
- A rational number for zero.
ExtendedRational Constructor
public ExtendedRational( PeterO.BigInteger numerator, PeterO.BigInteger denominator);
Initializes a new instance of the PeterO.ExtendedRational class.
Parameters:
numerator: An arbitrary-precision integer.
denominator: Another arbitrary-precision integer.
Exceptions:
- System.ArgumentNullException: The parameter numerator or denominator is null.
NaN
public static readonly PeterO.ExtendedRational NaN;
A not-a-number value.
NegativeInfinity
public static readonly PeterO.ExtendedRational NegativeInfinity;
Negative infinity, less than any other number.
NegativeZero
public static readonly PeterO.ExtendedRational NegativeZero;
A rational number for negative zero.
One
public static readonly PeterO.ExtendedRational One;
The rational number one.
PositiveInfinity
public static readonly PeterO.ExtendedRational PositiveInfinity;
Positive infinity, greater than any other number.
SignalingNaN
public static readonly PeterO.ExtendedRational SignalingNaN;
A signaling not-a-number value.
Ten
public static readonly PeterO.ExtendedRational Ten;
The rational number ten.
Zero
public static readonly PeterO.ExtendedRational Zero;
A rational number for zero.
Denominator
public PeterO.BigInteger Denominator { get; }
Gets this object's denominator.
Returns:
This object's denominator.
IsFinite
public bool IsFinite { get; }
Deprecated. Use ERational from PeterO.Numbers/com.upokecenter.numbers.
Gets a value indicating whether this object is finite (not infinity or NaN).
Returns:
true
If this object is finite (not infinity or NaN); otherwise, . false
.
IsNegative
public bool IsNegative { get; }
Gets a value indicating whether this object's value is negative (including negative zero).
Returns:
true
If this object's value is negative; otherwise, . false
.
IsZero
public bool IsZero { get; }
Deprecated. Use ERational from PeterO.Numbers/com.upokecenter.numbers.
Gets a value indicating whether this object's value equals 0.
Returns:
true
If this object's value equals 0; otherwise, . false
.
Numerator
public PeterO.BigInteger 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).
Sign
public int Sign { get; }
Deprecated. Use ERational from PeterO.Numbers/com.upokecenter.numbers.
Gets the sign of this rational number.
Returns:
Zero if this value is zero or negative zero; -1 if this value is less than 0; and 1 if this value is greater than 0.
UnsignedNumerator
public PeterO.BigInteger 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.
CompareTo
public sealed int CompareTo( PeterO.ExtendedRational other);
Compares this value to another.
Parameters:
- other: The parameter other is an ExtendedRational object.
Return Value:
Less than 0 if this value is less than, 0 if equal to, or greater than 0 if greater than the other value.
Create
public static PeterO.ExtendedRational Create( int numeratorSmall, int denominatorSmall);
Creates a rational number with the given numerator and denominator.
Parameters:
numeratorSmall: The parameter numeratorSmall is a 32-bit signed integer.
denominatorSmall: The parameter denominatorSmall is a 32-bit signed integer.
Return Value:
An arbitrary-precision rational number.
Create
public static PeterO.ExtendedRational Create( PeterO.BigInteger numerator, PeterO.BigInteger denominator);
Creates a rational number with the given numerator and denominator.
Parameters:
numerator: An arbitrary-precision integer.
denominator: Another arbitrary-precision integer.
Return Value:
An arbitrary-precision rational number.
Exceptions:
- System.ArgumentNullException: The parameter numerator or denominator is null.
Equals
public override bool Equals( object obj);
Checks whether this and another value are equal.
Parameters:
- obj: The parameter obj is an arbitrary object.
Return Value:
Either true
or false
.
Equals
public sealed bool Equals( PeterO.ExtendedRational other);
Checks whether this and another value are equal.
Parameters:
- other: The parameter other is an ExtendedRational object.
Return Value:
Either true
or false
.
GetHashCode
public override int GetHashCode();
Calculates the hash code for this object. No application or process IDs are used in the hash code calculation.
Return Value:
A 32-bit signed integer.
ToString
public override string ToString();
Converts this object to a text string.
Return Value:
A string representation of this object. The result can be Infinity, NaN, or sNaN (with a minus sign before it for negative values), or a number of the following form: [-]numerator/denominator.