Value class Null safety

Immutable calculator value

Floats are stored in something close to what I think is the 16C's internal format

This format is interesting. It's big-endian BCD. The mantissa is sign-magnitude, with the sign in a nybble that is 0 for positive, and 9 for negative. The exponent is 1000's complement BCD, with a magnitude between 0 and 99 (inclusive). So it looks like:

 smmmmmmmmmmeee

s = mantissa sign (0/9) m = mantissa magnitude e = exponent (1 is 001, -1 is 0x999, -2 is 0x998, etc)

The most significant digit of the mantissa is always non-zero. In other words, 0.1e-99 underflows to zero. The mantissa is NOT stored in complement form. So, a mantissa of -4.2 is 0x94200000000.

Note that I didn't refer to a ROM image to figure this out, or anything like that. I just asked what the behavior of the real calculator is for a couple of data points. cf. https://www.hpmuseum.org/forum/thread-16595-post-145554.html#pid145554

Annotations

Constructors

Value.fromInternal(BigInt internal)
Value.fromMatrix(int matrixNumber)

Properties

asDouble double
Interpret this value as a floating point, and convert to a double. There is no corresponding asInt method, because the int interpretation depends on the bit size and the sign mode - cf. IntegerSignMode.toBigInt()
read-only
asMatrix int?
If this is a matrix descriptor, give the matrix number, where A is 0.
read-only
exponent int
Get the exponent part of this value interpreted as a float. Not valid for infinity or -infinity.
read-only
floatPrefix String
read-only
hashCode int
The hash code for this object.
read-onlyoverride
internal BigInt
The calculator's internal representation of a value, as an unsigned integer of (up to) 64 bits in normal operation (128 for the double integer operations). It's a BigInt rather than an int because Javascript Is Evil (tm). That said, using BigInt does let us handle the double integer operations easily.
final
isNegative bool
read-only
isPositive bool
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

changeBitSize(BigInt bitMask) Value
fracOp() Value
intOp() Value
isZero(Model<ProgramOperation> m) bool
Determine if this value is zero. In 1's complement mode, -0 isZero, too.
mantissaDigit(int digit) int
Give one digit of the mantissa, where 0 is the MSD, and 9 is the LSD. -1 gives the sign digit (9 is negative, 0 is positive).
negateAsFloat() Value
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
timesTenTo(int power) Value
toJson() String
toString() String
A string representation of this object.
override

Operators

operator ==(Object? other) bool
The equality operator.
override

Static Properties

fInfinity Value
final
fMaxValue Value
final
fMinValue Value
final
fNegativeInfinity Value
final
oneF Value
final
zero Value
Zero for both floats and ints
final

Static Methods

fromDouble(double num) Value
fromJson(String v, {BigInt? maxInternal}) Value