GeorgeLeePatterson opened a new pull request, #321: URL: https://github.com/apache/arrow-js/pull/321
## Rationale for this change Integration tests were failing when JavaScript produced IntervalMonthDayNano data that was consumed by C++, Rust, or nanoarrow implementations. The nanosecond values differed by small amounts (e.g., 216 nanoseconds) due to precision loss during BigInt to Number conversion. **Example failure:** - Expected: `6684525287992311000ns` - JS Output: `6684525287992310784ns` - Difference: 216ns ## What changes are included in this PR? Fixed the `toIntervalMonthDayNanoInt32Array` function in `src/util/interval.ts` to properly handle unsigned 32-bit integer conversion without precision loss. The issue was that `Number(BigInt)` conversion for large values (>2^53-1) loses precision. Applied unsigned right shift (`>>> 0`) to ensure correct unsigned 32-bit representation. **Changed:** ```typescript // Before (loses precision): data[ai++] = Number(BigInt(nanoseconds) & BigInt(0xFFFFFFFF)); data[ai++] = Number(BigInt(nanoseconds) >> BigInt(32)); // After (preserves precision): const ns = BigInt(nanoseconds); data[ai++] = Number(ns & BigInt(0xFFFFFFFF)) >>> 0; data[ai++] = Number(ns >> BigInt(32)) >>> 0; Fixes apache/arrow#46203 -- 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]
