gruuya commented on PR #8700:
URL: https://github.com/apache/arrow-rs/pull/8700#issuecomment-3696913488

   That said, the following (valid) example will lead to an overflow again
   ```rust
   let result_128 = 
parse_decimal::<Decimal128Type>("20000000000000000000000000000000000002.0e-1", 
38, 0).unwrap();
   assert_eq!(result_128, 20000000000000000000000000000000000000);
   
   assertion `left == right` failed
     left: -1402823669209384634633746074317682114
    right: 20000000000000000000000000000000000000
   ```
   In fact this also happens with scale 1, and it happens on `main` as well (so 
this PR isn't introducing it).
   
   The main problem there is the way e-notation is parsed—by the time we hit 
e-notation processing we've already applied all the significant digits to the 
result without checking whether some of them are not needed (e.g. because of 
the negative exponent moving the decimal point to the left). Hence we may have 
overflowed by the point we want to do `div_wrapping`.
   
   To fix this i think we need to `s.split_once(['e', 'E'])` first, then 
optionally process the exponent, and only then move on to the mantissa, since 
then we know exactly what numbers can be thrown away. This however goes beyond 
the scope of this PR/issue I think, and probably requires more discussion 
(especially around performance implications).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to