Menu - Top - Home - Donate to Me

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

ExtendedRational Constructor

public ExtendedRational(
    PeterO.BigInteger numerator,
    PeterO.BigInteger denominator);

Initializes a new instance of the PeterO.ExtendedRational class.

Parameters:

Exceptions:

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:

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:

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:

Return Value:

An arbitrary-precision rational number.

Exceptions:

Equals

public override bool Equals(
    object obj);

Checks whether this and another value are equal.

Parameters:

Return Value:

Either true or false .

Equals

public sealed bool Equals(
    PeterO.ExtendedRational other);

Checks whether this and another value are equal.

Parameters:

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.

Back to CBOR start page.