Menu - Top - Home - Donate to Me

PeterO.ExtendedFloat

PeterO.ExtendedFloat

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

Deprecated. Use EFloat 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.EFloat in the PeterO.Numbers library (in .NET), or com.upokecenter.numbers.EFloat 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).

Represents an arbitrary-precision binary floating-point number. Consists of an integer mantissa and an integer exponent, both arbitrary-precision. The value of the number equals mantissa * 2^exponent. This class also supports values for negative zero, not-a-number (NaN) values, and infinity.

Passing a signaling NaN to any arithmetic operation shown here will signal the flag FlagInvalid and return a quiet NaN, even if another operand to that operation is a quiet NaN, unless noted otherwise.

Passing a quiet NaN to any arithmetic operation shown here will return a quiet NaN, unless noted otherwise.

Unless noted otherwise,passing a null arbitrary-precision binary float argument to any method here will throw an exception.

When an arithmetic operation signals the flag FlagInvalid, FlagOverflow, or FlagDivideByZero, it will not throw an exception too, unless the operation's trap is enabled in the precision context (see PrecisionContext's Traps property).

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

Member Summary

NaN

public static readonly PeterO.ExtendedFloat NaN;

A not-a-number value.

NegativeInfinity

public static readonly PeterO.ExtendedFloat NegativeInfinity;

Negative infinity, less than any other number.

NegativeZero

public static readonly PeterO.ExtendedFloat NegativeZero;

Represents the number negative zero.

One

public static readonly PeterO.ExtendedFloat One;

Represents the number 1.

PositiveInfinity

public static readonly PeterO.ExtendedFloat PositiveInfinity;

Positive infinity, greater than any other number.

SignalingNaN

public static readonly PeterO.ExtendedFloat SignalingNaN;

A not-a-number value that signals an invalid operation flag when it's passed as an argument to any arithmetic operation in arbitrary-precision binary float.

Ten

public static readonly PeterO.ExtendedFloat Ten;

Represents the number 10.

Zero

public static readonly PeterO.ExtendedFloat Zero;

Represents the number 0.

Exponent

public PeterO.BigInteger Exponent { get; }

Gets this object's exponent. This object's value will be an integer if the exponent is positive or zero.

Returns:

This object's exponent. This object's value will be an integer if the exponent is positive or zero.

IsNegative

public bool IsNegative { get; }

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Gets a value indicating whether this object is negative, including negative zero.

Returns:

true If this object is negative, including negative zero; otherwise, . false .

Mantissa

public PeterO.BigInteger Mantissa { get; }

Gets this object's un-scaled value.

Returns:

This object's un-scaled value. Will be negative if this object's value is negative (including a negative NaN).

Sign

public int Sign { get; }

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Gets this value's sign: -1 if negative; 1 if positive; 0 if zero.

Returns:

This value's sign: -1 if negative; 1 if positive; 0 if zero.

UnsignedMantissa

public PeterO.BigInteger UnsignedMantissa { get; }

Gets the absolute value of this object's un-scaled value.

Returns:

The absolute value of this object's un-scaled value.

CompareTo

public sealed int CompareTo(
    PeterO.ExtendedFloat other);

Compares this extended float 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.ExtendedFloat Create(
    int mantissaSmall,
    int exponentSmall);

Creates a number with the value exponent*2^mantissa.

Parameters:

Return Value:

An arbitrary-precision binary float.

Create

public static PeterO.ExtendedFloat Create(
    PeterO.BigInteger mantissa,
    PeterO.BigInteger exponent);

Creates a number with the value exponent*2^mantissa.

Parameters:

Return Value:

An arbitrary-precision binary float.

Exceptions:

Equals

public override bool Equals(
    object obj);

Determines whether this object's mantissa and exponent are equal to those of another object and that other object is an arbitrary-precision decimal number.

Parameters:

Return Value:

true if the objects are equal; otherwise, false .

Equals

public sealed bool Equals(
    PeterO.ExtendedFloat other);

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Determines whether this object's mantissa and exponent are equal to those of another object.

Parameters:

Return Value:

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

Exceptions:

EqualsInternal

public bool EqualsInternal(
    PeterO.ExtendedFloat otherValue);

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Determines whether this object's mantissa and exponent are equal to those of another object.

Parameters:

Return Value:

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

Exceptions:

FromString

public static PeterO.ExtendedFloat FromString(
    string str);

Creates a binary float from a text string that represents a number.

Parameters:

Return Value:

The parsed number, converted to arbitrary-precision binary float.

FromString

public static PeterO.ExtendedFloat FromString(
    string str,
    int offset,
    int length,
    PeterO.PrecisionContext ctx);

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Creates a binary float from a text string that represents a number. Note that if the string contains a negative exponent, the resulting value might not be exact, in which case the resulting binary float will be an approximation of this decimal number's value. (NOTE: This documentation previously said the binary float will contain enough precision to accurately convert it to a 32-bit or 64-bit floating point number. Due to double rounding, this will generally not be the case for certain numbers converted from decimal to ExtendedFloat via this method and in turn converted to double or float .) The format of the string generally consists of:

Return Value:

The parsed number, converted to arbitrary-precision binary float.

Exceptions:

GetHashCode

public override int GetHashCode();

Calculates this object's hash code. No application or process IDs are used in the hash code calculation.

Return Value:

This object's hash code.

IsInfinity

public bool IsInfinity();

Gets a value indicating whether this object is positive or negative infinity.

Return Value:

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

IsNaN

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 .

IsNegativeInfinity

public bool IsNegativeInfinity();

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Returns whether this object is negative infinity.

Return Value:

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

IsPositiveInfinity

public bool IsPositiveInfinity();

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Returns whether this object is positive infinity.

Return Value:

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

IsQuietNaN

public bool IsQuietNaN();

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Gets a value indicating whether this object is a quiet not-a-number value.

Return Value:

true if this object is a quiet not-a-number value; otherwise, false .

IsSignalingNaN

public bool IsSignalingNaN();

Deprecated. Use EFloat from PeterO.Numbers/com.upokecenter.numbers.

Gets a value indicating whether this object is a signaling not-a-number value.

Return Value:

true if this object is a signaling not-a-number value; otherwise, false .

ToString

public override string ToString();

Converts this value to a string.

Return Value:

A string representation of this object. The value is converted to decimal and the decimal form of this number's value is returned.

Back to CBOR start page.