Skip to main content

signed_parse_units

Function signed_parse_units 

Source
fn signed_parse_units(value: &NumberWithBase) -> Result<ParseUnits>
Expand description

Converts a parsed, possibly-negative NumberWithBase into a ParseUnits, preserving its sign.

NumberWithBase::number() returns the two’s-complement bits of a negative value modulo 2^256, which is a wider range than I256 can represent (magnitudes up to 2^255 only). A magnitude beyond that range would silently reinterpret as a small positive I256 if constructed unconditionally via I256::from_raw – reject it instead.