FloatingPointValue class

A flexible representation of floating point values. A FloatingPointValue hasa mantissa in [0,2) with 0 <= exponent <= maxExponent(); A normal isNormal FloatingPointValue 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({required LogicValue sign, required LogicValue exponent, required LogicValue mantissa})
Constructor for a FloatingPointValue with a sign, exponent, and mantissa.
FloatingPointValue.getFloatingPointConstant(FloatingPointConstants constantFloatingPoint, int exponentWidth, int mantissaWidth)
Return the FloatingPointValue representing the constant specified
factory
FloatingPointValue.ofBigInts(BigInt exponent, BigInt mantissa, {int exponentWidth = 0, int mantissaWidth = 0, bool sign = false})
FloatingPointValue constructor from a set of BigInts of the binary representation and the size of the exponent and mantissa
FloatingPointValue.ofBinaryStrings(String sign, String exponent, String mantissa)
FloatingPointValue constructor from a binary string representation of individual bitfields
FloatingPointValue.ofDouble(double inDouble, {required int exponentWidth, required int mantissaWidth, FloatingPointRoundingMode roundingMode = FloatingPointRoundingMode.roundNearestEven})
Convert from double using its native binary representation
factory
FloatingPointValue.ofDoubleUnrounded(double inDouble, {required int exponentWidth, required int mantissaWidth})
Convert a floating point number into a FloatingPointValue representation. This form performs NO ROUNDING.
factory
FloatingPointValue.ofInts(int exponent, int mantissa, {int exponentWidth = 0, int mantissaWidth = 0, bool sign = false})
FloatingPointValue constructor from a set of ints of the binary representation and the size of the exponent and mantissa
FloatingPointValue.ofLogicValue(int exponentWidth, int mantissaWidth, LogicValue val)
Construct a FloatingPointValue from a LogicValue
factory
FloatingPointValue.ofSpacedBinaryString(String fp)
FloatingPointValue constructor from a single binary string representing space-separated bitfields
FloatingPointValue.ofString(String fp, int exponentWidth, int mantissaWidth, {int radix = 2})
FloatingPointValue constructor from a radix-encoded string representation and the size of the exponent and mantissa
FloatingPointValue.random(Random rv, {required int exponentWidth, required int mantissaWidth, bool normal = false})
Generate a random FloatingPointValue, supplying random seed rv. This generates a valid FloatingPointValue anywhere in the range it can represent:a general FloatingPointValue has a mantissa in [0,2) with 0 <= exponent <= maxExponent(); If normal is true, This routine will only generate mantissas in the range of [1,2) and minExponent() <= exponent <= maxExponent().
factory
FloatingPointValue.withMappedSubtype({required LogicValue sign, required LogicValue exponent, required LogicValue mantissa})
Constructs a FloatingPointValue with a sign, exponent, and mantissa using one of the builders provided from subtypeConstructorMap if available, otherwise using the default constructor.
factory

Properties

bias int
Return the bias of this FloatingPointValue.
no setter
constrainedExponentWidth int?
constrainedExponentWidth is the hard-coded exponent width of the sub-class of this floating-point value
no setter
constrainedMantissaWidth int?
constrainedMantissaWidth is the hard-coded mantissa width of the sub-class of this floating-point value
no setter
exponent LogicValue
The exponent of the floating point: this is biased about a midpoint for positive and negative exponents
final
hashCode int
The hash code for this object.
no setteroverride
mantissa LogicValue
The mantissa of the floating point
final
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 value: 1 means a negative value
final
value LogicValue
The full floating point value bit storage
final

Methods

abs() FloatingPointValue
Absolute value operation for FloatingPointValue
compareTo(Object other) int
Floating point comparison to implement Comparable<>
override
isNaN() bool
Return true if the represented floating point number is considered NaN or 'Not a Number' due to overflow
isNormal() bool
Return a Logic true if this FloatingPointVa;ie contains a normal number, defined as having mantissa in the range [1,2)
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.
toMappedSubtype() FloatingPointValue
Converts this FloatingPointValue to a FloatingPointValue with the same sign, exponent, and mantissa using the constructor provided in subtypeConstructorMap if available, otherwise using the default constructor.
toString({bool integer = false}) String
Return a string representation of FloatingPointValue. if integer is true, return sign, exponent, mantissa as integers. if integer is false, return sign, exponent, mantissa as ibinary strings.
override

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 ==(Object other) bool
Return the bias of this FP format
override

Static Properties

subtypeConstructorMap Map<({int exponentWidth, int mantissaWidth}), FloatingPointValue Function({required LogicValue exponent, required LogicValue mantissa, required LogicValue sign})>
A mapping from a ({exponentWidth, mantissaWidth}) record to a constructor for a specific FloatingPointValue subtype. This map is used by the FloatingPointValue.withMappedSubtype constructor to select the appropriate constructor for a given set of widths.
getter/setter pair

Static Methods

buildOfLogicValue<T extends FloatingPointValue>(T constructor({required LogicValue exponent, required LogicValue mantissa, required LogicValue sign}), int exponentWidth, int mantissaWidth, LogicValue val) → T
A helper function for FloatingPointValue.ofLogicValue and base classes which performs some width checks and slicing.
computeBias(int exponentWidth) int
Return the exponent value representing the true zero exponent 2^0 = 1 often termed computeBias or the offset of the exponent
computeMaxExponent(int exponentWidth) int
Return the maximum exponent value
computeMinExponent(int exponentWidth) int
Return the minimum exponent value