pub fn numeric_to_string(bytes: &[u8]) -> Result<String>Expand description
Converts PostgreSQL NUMERIC binary encoding to String.
Based on PostgreSQL’s get_str_from_var() from numeric.c:
https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/numeric.c
Binary format:
- 2 bytes: ndigits (number of base-10000 digits)
- 2 bytes: weight (position of first digit relative to decimal point)
- 2 bytes: sign (0x0000=positive, 0x4000=negative, 0xC000=NaN, 0xD000=+Inf, 0xF000=-Inf)
- 2 bytes: dscale (display scale)
- ndigits * 2 bytes: digits (each 0-9999 in base 10000)