Table of Contents

Struct Float80

Namespace
RDCore.SDK.Model.Values.Numerics
Assembly
RDCore.SDK.dll

An 80-bit extended-precision binary floating-point number, as an x87 floating-point unit computes with: a sign, a 15-bit exponent and a 64-bit significand, rounded to nearest, ties to even.

public readonly struct Float80 : IEquatable<Float80>
Implements
Inherited Members

Remarks

MS-VBAL 5.6.9.3 lets an implementation "perform floating point operations with a higher-precision than the effective value type (such as an 'extended' or 'long double' type)", and MS-VBA does: an expression of Single and Double operands is computed in this format, and its value is rounded to the effective type where it is stored. So (1E+308 * 10) / 10 is 1E+308 with no overflow, and 0.1 + 0.2 - 0.3 is 2.77555756156289E-17, where an evaluation in Double gives 5.55111512312578E-17.

Every operation is correctly rounded, as IEEE 754 requires of the basic operations, and reports the FloatingPointExceptions it signals; a NaN produced by an invalid operation is the x87's default NaN (the "real indefinite", negative, which VBA writes -nan(ind)), and an operation of a NaN gives that NaN back, made quiet. Rounding to double or float (ToDouble(out FloatingPointExceptions), ToSingle(out FloatingPointExceptions)) is what storing the value in a variable of that type does: it is a second rounding, of the value already rounded to 64 bits.

Properties

Indefinite

The NaN an invalid operation produces: the x87's "real indefinite", a negative quiet NaN, which VBA writes -nan(ind).

public static Float80 Indefinite { get; }

Property Value

Float80

IsFinite

Whether the value is a number: neither an infinity nor a NaN.

public bool IsFinite { get; }

Property Value

bool

IsInfinity

Whether the value is an infinity, of either sign.

public bool IsInfinity { get; }

Property Value

bool

IsNaN

Whether the value is a NaN.

public bool IsNaN { get; }

Property Value

bool

IsNegative

Whether the sign bit is set: a negative number, negative zero, or a NaN whose sign is negative.

public bool IsNegative { get; }

Property Value

bool

IsZero

Whether the value is zero, of either sign.

public bool IsZero { get; }

Property Value

bool

NegativeInfinity

Negative infinity.

public static Float80 NegativeInfinity { get; }

Property Value

Float80

PositiveInfinity

Positive infinity.

public static Float80 PositiveInfinity { get; }

Property Value

Float80

SignAndExponent

The sign bit (bit 15) and the biased exponent (bits 0-14) of the value, as the x87 format encodes them.

public ushort SignAndExponent { get; }

Property Value

ushort

Significand

The 64-bit significand of the value, with its explicit integer bit (bit 63), as the x87 format encodes it.

public ulong Significand { get; }

Property Value

ulong

Zero

Positive zero.

public static Float80 Zero { get; }

Property Value

Float80

Methods

Abs()

The value with its sign cleared. A NaN's sign is cleared too, with no exception.

public Float80 Abs()

Returns

Float80

Add(Float80, Float80, out FloatingPointExceptions)

The sum of two values, correctly rounded.

public static Float80 Add(Float80 a, Float80 b, out FloatingPointExceptions exceptions)

Parameters

a Float80

The augend.

b Float80

The addend.

exceptions FloatingPointExceptions

The exceptions the operation signals: Invalid for infinities of opposite signs.

Returns

Float80

Compare(Float80, Float80)

Compares two values as IEEE 754 orders them: negative and positive zero are equal, and a NaN is ordered with nothing.

public static int? Compare(Float80 a, Float80 b)

Parameters

a Float80
b Float80

Returns

int?

A negative number, zero or a positive number as a is less than, equal to or greater than b; or null when either is a NaN.

Divide(Float80, Float80, out FloatingPointExceptions)

The quotient of two values, correctly rounded.

public static Float80 Divide(Float80 a, Float80 b, out FloatingPointExceptions exceptions)

Parameters

a Float80

The dividend.

b Float80

The divisor.

exceptions FloatingPointExceptions

The exceptions the operation signals: Invalid for zero divided by zero and infinity divided by infinity, DivideByZero for any other finite number divided by zero, Overflow past the range of the format.

Returns

Float80

Equals(Float80)

Whether two values have the same encoding: a bitwise comparison, under which a NaN equals itself and the two zeros differ.

public bool Equals(Float80 other)

Parameters

other Float80

Returns

bool

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromCurrency(long)

The value of a Currency: its ten-thousandths divided by 10,000, rounded once.

public static Float80 FromCurrency(long scaled)

Parameters

scaled long

The value of the Currency, in ten-thousandths.

Returns

Float80

FromDouble(double)

The value of a double, exactly: every Double is a value of this format.

public static Float80 FromDouble(double value)

Parameters

value double

The value to convert.

Returns

Float80

FromInt64(long)

The value of a 64-bit integer, exactly: the significand holds every LongLong.

public static Float80 FromInt64(long value)

Parameters

value long

The value to convert.

Returns

Float80

FromSingle(float)

The value of a float, exactly: every Single is a value of this format.

public static Float80 FromSingle(float value)

Parameters

value float

The value to convert.

Returns

Float80

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Multiply(Float80, Float80, out FloatingPointExceptions)

The product of two values, correctly rounded.

public static Float80 Multiply(Float80 a, Float80 b, out FloatingPointExceptions exceptions)

Parameters

a Float80

The multiplicand.

b Float80

The multiplier.

exceptions FloatingPointExceptions

The exceptions the operation signals: Invalid for zero times infinity, Overflow past the range of the format.

Returns

Float80

Negate()

The value with its sign inverted. A NaN is negated too, with no exception.

public Float80 Negate()

Returns

Float80

RoundToDoublePrecision()

The value rounded to the 53 bits of a Double's significand, in the range of this format: what the x87 does to a value it keeps, with its precision control set to double precision. No value overflows.

public Float80 RoundToDoublePrecision()

Returns

Float80

RoundToIntegral(MidpointRounding)

The integer the value rounds to - to nearest, ties to even (ToEven); toward zero (ToZero, VBA's Fix); toward negative infinity (ToNegativeInfinity, VBA's Int); or toward positive infinity (ToPositiveInfinity). An infinity, a NaN and zero are themselves.

public Float80 RoundToIntegral(MidpointRounding mode)

Parameters

mode MidpointRounding

The direction of the rounding.

Returns

Float80

RoundToSinglePrecision()

The value rounded to the 24 bits of a Single's significand, in the range of this format. No value overflows.

public Float80 RoundToSinglePrecision()

Returns

Float80

Subtract(Float80, Float80, out FloatingPointExceptions)

The difference of two values, correctly rounded.

public static Float80 Subtract(Float80 a, Float80 b, out FloatingPointExceptions exceptions)

Parameters

a Float80

The minuend.

b Float80

The subtrahend.

exceptions FloatingPointExceptions

The exceptions the operation signals: Invalid for infinities of the same sign.

Returns

Float80

ToDouble(out FloatingPointExceptions)

The value rounded to a double, to nearest, ties to even: what storing it in a Double does. A value past the range of a Double is an infinity, and signals Overflow; a NaN keeps its sign and the high bits of its payload.

public double ToDouble(out FloatingPointExceptions exceptions)

Parameters

exceptions FloatingPointExceptions

The exceptions the rounding signals.

Returns

double

ToSingle(out FloatingPointExceptions)

The value rounded to a float, to nearest, ties to even: what storing it in a Single does. A value past the range of a Single is an infinity, and signals Overflow.

public float ToSingle(out FloatingPointExceptions exceptions)

Parameters

exceptions FloatingPointExceptions

The exceptions the rounding signals.

Returns

float

ToString()

The value rounded to a double, and its encoding.

public override string ToString()

Returns

string

TryToInt64(out long)

The value as a 64-bit integer, when it is an integer of that range.

public bool TryToInt64(out long value)

Parameters

value long

The integer, or 0.

Returns

bool

Whether the value is an integer from MinValue to MaxValue.