Skip to main content

Module decimal

Module decimal 

Source
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 provides one pure function — decimal_str_to_scaled_i128 — that converts a DB text-protocol decimal string to the scaled i128 Arrow needs without ever touching floating-point arithmetic.

Functions§

decimal_str_to_scaled_i128
scaled_i128_to_decimal_str
Convert a decimal string (as returned by the database text protocol) to a scaled i128 ready to be stored in an Arrow Decimal128 array.