You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scale is used in exactly three places in parse_decimal, and all three assume it's >= 0:
:981if fractionals == scale — the stop condition for consuming fractional digits. Never true for a negative scale, so the whole fraction gets consumed.
:1021if fractionals < scale — the only rescaling step. Also never true.
:1024, the multiply inside it.
result is only ever multiplied in this function; there is no division anywhere. A negative scale needs result / 10^-scale and there's no code path for it, so what comes back is the mantissa digits with the decimal point deleted:
This only reaches callers who use parse_decimal directly — cast_string_to_decimal refuses negative scale up front at cast/decimal.rs:798, which is the other side of #10792.
Activity
neilconway commentedon Aug 21, 2026
take
[-]`parse_decimal ignores negative scales`[/-][+]`parse_decimal` ignores negative scales[/+]Lstarsky0 commentedon Aug 23, 2026
scaleis used in exactly three places inparse_decimal, and all three assume it's>= 0::981if fractionals == scale— the stop condition for consuming fractional digits. Never true for a negative scale, so the whole fraction gets consumed.:1021if fractionals < scale— the only rescaling step. Also never true.:1024, the multiply inside it.resultis only ever multiplied in this function; there is no division anywhere. A negative scale needsresult / 10^-scaleand there's no code path for it, so what comes back is the mantissa digits with the decimal point deleted:This only reaches callers who use
parse_decimaldirectly —cast_string_to_decimalrefuses negative scale up front atcast/decimal.rs:798, which is the other side of #10792.Consolidate string-to-decimal parsing into a single code path
fix: Consolidate string-to-decimal parsing into a single code path (#…
fix: Consolidate string-to-decimal parsing into a single code path (a…
fix: Consolidate string-to-decimal parsing into a single code path (a…
fix: Consolidate string-to-decimal parsing into a single code path (a…