miguelcorderopamphile commented on issue #11314:
URL: https://github.com/apache/arrow-rs/issues/11314#issuecomment-5926494597

   I reproduced this on main with the exact case: `(1_i128 << 63) + 1024 + 1` 
returns the lower neighbor (`0x43e0000000000000`) while `i128 as f64` gives 
`0x43e0000000000001`.
   
   Root cause: `i256_to_f64` normalizes and keeps the top 64 bits, discarding 
the lower 192, so the final `i64 as f64` rounds the truncated value and a 
non-zero tail cannot push an exact binary64 midpoint to the correct side. I 
validated the sticky-bit approach against correctly rounded conversions over 
midpoint neighborhoods and random inputs before implementing (a naive `+1` 
variant turned out to be incorrect).
   
   PR: https://github.com/apache/arrow-rs/pull/11315


-- 
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