Class ImpliedTextNumber
java.lang.Object
dev.frostlake.executor.expressions.ImpliedTextNumber
How a TEXT reads as a number in exact arithmetic —
t + 0, t * n, MOD(t, 2),
ROUND(t, 1) — live-verified over VARCHAR columns of every declared length and over
literals:
- a text COLUMN or expression reads as
NUMBER(18,5):t + 0declares NUMBER(19,5) and answers5.00000,t / 1NUMBER(24,11),t % 2NUMBER(18,5); the value is rounded HALF_UP to five decimals before the operation ('1.123456' + 0is 1.12346); - a text LITERAL reads as
NUMBER(18, s)with ITS OWN scale:'5' + 1declares NUMBER(19,0) and answers 6,'2.5' + 1NUMBER(19,1) and 3.5,MOD('5', 2)NUMBER(2,0); - text beside text, beside a FLOAT, beside a VARIANT or beside a bare NULL is a FLOAT, as is a VARIANT beside anything and a signed text — those are not this reading.
The reading refuses at row time: a text spelling no number is Numeric value 'x' is not
recognized; so is one whose five-decimal reading overflows the eighteen digits the account parses
it into (an unscaled value past 9223372036854775807 — '99999999999999',
'123456789012345', '1e14', '1e30'); one that parses but carries more than
thirteen whole digits is Numeric value '12345678901234' is out of range — so is
'1e13' and '9999999999999.999995', which rounds up to fourteen. Spellings a literal
has are all read: ' 5 ', '.5', '5.', '+5', '5e2',
'0000000000000005'.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NumericTypeThe number a text column reads as in exact arithmetic. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisTextLiteral(Expression expr) Whether an expression is a text literal, whose reading keeps its own scale.static NumericTypeliteralOwnWidth(String text) The number a text literal reads as under the remainder operator and MOD: its own digits, as a numeric literal of the same spelling would —'5'NUMBER(1,0),'12345'NUMBER(5,0),'2.5'NUMBER(2,1) — or null when the text spells no number.static NumericTypeliteralReading(String text) The number a text LITERAL reads as: eighteen digits at the literal's own scale, or null when the text spells no number (the row-time refusal is then the operation's own).static BigDecimalread(CharSequence text) A text column's value read as NUMBER(18,5), or the row-time refusal.
-
Field Details
-
COLUMN_READING
The number a text column reads as in exact arithmetic.
-
-
Method Details
-
literalReading
The number a text LITERAL reads as: eighteen digits at the literal's own scale, or null when the text spells no number (the row-time refusal is then the operation's own).- Parameters:
text- the literal's text- Returns:
- NUMBER(18, s), or null
-
literalOwnWidth
The number a text literal reads as under the remainder operator and MOD: its own digits, as a numeric literal of the same spelling would —'5'NUMBER(1,0),'12345'NUMBER(5,0),'2.5'NUMBER(2,1) — or null when the text spells no number.- Parameters:
text- the literal's text- Returns:
- the literal's own width, or null
-
isTextLiteral
Whether an expression is a text literal, whose reading keeps its own scale.- Parameters:
expr- the operand- Returns:
- true for a quoted string literal
-
read
A text column's value read as NUMBER(18,5), or the row-time refusal.- Parameters:
text- the cell- Returns:
- the value at scale five
-