Package dev.frostlake.executor
Class SignedStorageWidth
java.lang.Object
dev.frostlake.executor.SignedStorageWidth
The
SBn tag Snowflake prints for a fixed-point number — the smallest SIGNED-INTEGER width, in
bytes, that holds the number's unscaled value. Two live surfaces spell it and they agree, which is why
the rule lives in one place: SYSTEM$TYPEOF tags the value it is handed, and the
out-of-representable-range refusal tags either the value it could not store or the column it could not
store it in.
★ THE BOUNDARIES ARE THE JAVA ONES, measured rather than assumed: 127 is SB1 and 128 is SB2, 32767
is SB2 and 32768 is SB4, and the ladder continues at Integer.MAX_VALUE and Long.MAX_VALUE.
A DIGIT-counting rule looks equivalent and is not — a NUMBER(2,0) is SB1 because 99 fits in a byte, so
a "two digits means the two-byte class" reading is wrong at the first cell it meets. The bounds are
SIGNED, so -128 is still SB1 where a magnitude rule would say SB2 (live-verified).
★ THE SCALE SHIFTS THE VALUE BEFORE THE TAG IS READ, so the tag counts the digits STORAGE holds rather than the ones the number is written with: 12.39 in a NUMBER(2,1) is 124 (SB1), not 1239 (SB2).
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringThe tag forvalueonce shifted toscale.static StringtagOfPrecision(int precision) The tag for the WIDEST value a NUMBER(precision, s) can hold — the class of the column itself rather than of anything written to it.static StringtagOfRange(ValueRange range, int scale) The tag for every value of an interval once shifted toscale: the wider of its two ends, which is how the account tags a column — by its statistics, never by the row in hand.
-
Method Details
-
tagOf
The tag forvalueonce shifted toscale. -
tagOfRange
The tag for every value of an interval once shifted toscale: the wider of its two ends, which is how the account tags a column — by its statistics, never by the row in hand. An empty interval takes the narrowest tag, like a NULL. -
tagOfPrecision
The tag for the WIDEST value a NUMBER(precision, s) can hold — the class of the column itself rather than of anything written to it. The scale drops out: a NUMBER(5,2) holds 999.99, whose unscaled 99999 is the same quantity a NUMBER(5,0) holds.
-