Skip to content

feat: u32 -> integer64, rename scan_na to check, catch unsigned wraps#196

Merged
sebffischer merged 2 commits into
mainfrom
feat/check-arg-and-u32-integer64
May 18, 2026
Merged

feat: u32 -> integer64, rename scan_na to check, catch unsigned wraps#196
sebffischer merged 2 commits into
mainfrom
feat/check-arg-and-u32-integer64

Conversation

@sebffischer
Copy link
Copy Markdown
Collaborator

No description provided.

sebffischer and others added 2 commits May 18, 2026 12:35
Two related changes:

1. Materialize `ui32` buffers as `bit64::integer64` instead of base
   `integer`. R's signed int32 has no headroom for `ui32` values
   `>= 2^31` — they previously wrapped to negative integers silently
   (except for the single `INT_MIN` bit pattern, which became `NA` and
   was caught by `scan_na`). `integer64` has 53 bits of headroom over
   `ui32`'s range, so every value round-trips losslessly.

2. Rename `scan_na` to `check`, broaden it to also detect unsigned wrap.
   `check = TRUE` now errors when device -> host materialization yields:
   * An `NA` for `i32` / `i64` (the `INT_MIN` / `INT64_MIN` NA collision),
   * A negative `integer64` for `ui32` / `ui64` (which can only happen
     for `ui64 >= 2^63`; `ui32` is now lossless and never produces one).

The C++ `raw_to_array_impl` template's "integer64 storage" path now
matches `uint32_t` alongside `int64_t` / `uint64_t`, and dispatch in
`impl_raw_to_array` routes `ui32` through REALSXP. The R-side
`value.PJRTArrayPromise` extends its integer64 classing list to include
`ui32`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ui32 is materialized as integer64 with 53 bits of headroom over the
unsigned-32 range, so it can never produce a wrapped or NA value — the
check for ui32 was dead. Limit the negativity check to ui64 only and
update the docstring.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sebffischer sebffischer reopened this May 18, 2026
@sebffischer sebffischer merged commit 11c7174 into main May 18, 2026
24 of 26 checks passed
@sebffischer sebffischer deleted the feat/check-arg-and-u32-integer64 branch May 18, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant