Expand description
Exact decimal string → scaled integer conversion (roadmap §12).
The rule from the roadmap: never convert decimal through f64.
Arrow Decimal128 stores a value as i128 * 10^(-scale). So to
represent “123.45” in Decimal128(18, 2) we need i128 = 12345.
This module converts a DB text-protocol decimal string to the scaled
integer Arrow needs without ever touching floating-point arithmetic —
i128 for Decimal128 (precision ≤ 38) and i256 for Decimal256
(precision 39–76).
Functions§
- decimal_
str_ to_ scaled_ i128 - decimal_
str_ to_ scaled_ i256 Decimal256analogue ofdecimal_str_to_scaled_i128— parses straight intoi256so values beyondi128(precision 39–76) are not truncated. ReturnsNonefor empty / non-numeric strings ori256overflow.- scale_
int_ to_ i256 - Scale an integer (already widened to
i128) by10^scaleintoi256— theDecimal256analogue of the source drivers’scale_int_to_i128.Noneon negative scale ori256overflow. - scaled_
i128_ to_ decimal_ str - Convert a decimal string (as returned by the database text protocol) to
a scaled
i128ready to be stored in an ArrowDecimal128array.