FloatingPointValue class
A flexible representation of floating point values. A FloatingPointValue
has a mantissa in [0,2)
with 0 <= exponent <= maxExponent();
A value
which FloatingPointValue.isNormal has minExponent() <= exponent <= maxExponent()
and a mantissa in the range of [1,2)
. Subnormal numbers
are represented with a zero exponent and leading zeros in the mantissa
capture the negative exponent value.
- Implemented types
- Implementers
- Annotations
Constructors
- FloatingPointValue.new({required LogicValue sign, required LogicValue exponent, required LogicValue mantissa, bool explicitjBit = false, bool subNormalAsZero = false})
-
Constructor for a FloatingPointValue with the provided
sign
,exponent
, andmantissa
.factory - FloatingPointValue.uninitialized({bool explicitJBit = false, bool subNormalAsZero = false})
- Creates an unpopulated version of a FloatingPointValue, intended to be called with the populator.
Properties
- bias → int
-
Return the bias of this FloatingPointValue, the offset of the
exponent, also representing the zero exponent
2^0 = 1
.no setter - explicitJBit → bool
-
Return
true
if the JBit is explicitly represented in the mantissa.no setter - exponent ↔ LogicValue
-
The exponent of the FloatingPointValue: this is biased about a midpoint
for positive and negative exponents.
latefinal
- exponentWidth → int
-
The exponent width.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isAnInfinity → bool
-
Return
true
if the represented floating point number is considered infinity or negative infinity.no setter - isAZero → bool
-
Return
true
if the represented floating point number is zero. Note that the equality operator will treat FloatingPointConstants.positiveZero and FloatingPointConstants.negativeZero as equal.no setter - isExponentAllOnes → bool
-
Test if exponent is all '1's.
no setter
- isExponentAllZeros → bool
-
Test if exponent is all '0's.
no setter
- isMantissaAllZeroes → bool
-
Test if mantissa is all '0's.
no setter
- isNaN → bool
-
Return
true
if the represented floating point number is considered NaN or "Not a Number".no setter - mantissa ↔ LogicValue
-
The mantissa of the floating point.
latefinal
- mantissaWidth → int
-
The mantissa width.
no setter
- maxExponent → int
-
Return the maximum exponent of this FloatingPointValue.
no setter
- minExponent → int
-
Return the minimum exponent of this FloatingPointValue.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sign ↔ LogicValue
-
The sign of the FloatingPointValue: 1 means a negative value.
latefinal
- subNormalAsZero → bool
-
Return
true
if subnormal numbers are treated as zero.no setter - supportsInfinities → bool
-
Indicates whether FloatingPointConstants.positiveInfinity and
FloatingPointConstants.negativeInfinity representations are supported.
no setter
- value → LogicValue
-
The full floating point value concatenated as a LogicValue.
latefinal
Methods
-
abs(
) → FloatingPointValue - Absolute value operation for FloatingPointValue.
-
canonicalize(
) → FloatingPointValue - Return the cananocalized form of FloatingPointValue which has the leading 1 at the front of the mantissa, or further right if subnormal.
-
clonePopulator(
) → FloatingPointValuePopulator< FloatingPointValue> -
Creates a FloatingPointValuePopulator for the same type as
this
and with the same widths. -
compareTo(
Object other) → int -
Floating point comparison to implement Comparable.
override
-
getSpecialConstantComponents(
FloatingPointConstants constantFloatingPoint) → ({LogicValue exponent, LogicValue mantissa, LogicValue sign})? -
Returns a tuple of LogicValues for the sign, exponent, and
mantissa components of a special constant, or
null
if the constant does not have special components.This is useful for constants like NaN, infinity, etc., in certain types of floating point representations. -
isLegalValue(
) → bool - Check if the mantissa and exponent stored are compatible.
-
isNormal(
) → bool -
Return
true
if this FloatingPointValue contains a normal number, defined as having mantissa in the range[1,2)
. -
isSubnormal(
) → bool -
Return
true
if the represented floating point number is considered "subnormal", including isAZero. -
negate(
) → FloatingPointValue - Negate operation for FloatingPointValue.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDouble(
) → double - Return the value of the floating point number in a Dart double type.
-
toString(
{bool integer = false}) → String -
Return a string representation of FloatingPointValue.
override
-
ulp(
) → FloatingPointValue - Compute the unit in the last place for the given FloatingPointValue.
-
validate(
) → void - Validate the FloatingPointValue to ensure widths and other characteristics are legal.
-
withinRounding(
FloatingPointValue other) → bool -
Return
true
if the other FloatingPointValue is within a rounding error of this value.
Operators
-
operator *(
FloatingPointValue multiplicand) → FloatingPointValue - Multiply operation for FloatingPointValue.
-
operator +(
FloatingPointValue addend) → FloatingPointValue - Addition operation for FloatingPointValue.
-
operator -(
FloatingPointValue subend) → FloatingPointValue - Subtract operation for FloatingPointValue.
-
operator /(
FloatingPointValue divisor) → FloatingPointValue - Divide operation for FloatingPointValue.
-
operator <(
FloatingPointValue other) → bool - Less-than operator for FloatingPointValue.
-
operator <=(
FloatingPointValue other) → bool - Less-than-or-equal operator for FloatingPointValue.
-
operator ==(
Object other) → bool -
Equality operator for FloatingPointValue.
override
-
operator >(
FloatingPointValue other) → bool - Greater-than operator for FloatingPointValue.
-
operator >=(
FloatingPointValue other) → bool - Greater-than-or-equal operator for FloatingPointValue.
-
operator unary-(
) → FloatingPointValue - Negate the FloatingPointValue.
Static Methods
-
populator(
{required int exponentWidth, required int mantissaWidth, bool explicitJBit = false, bool subNormalAsZero = false}) → FloatingPointValuePopulator< FloatingPointValue> -
Creates a FloatingPointValuePopulator with the provided
exponentWidth
andmantissaWidth
, which can then be used to complete construction of a FloatingPointValue using population functions.