Skip to content

fix(base): preserve wide finite values in F32.to_nat - #1642

Open
oxura wants to merge 2 commits into
bendlang:mainfrom
oxura:fix/f32-to-nat-wide-20261017
Open

oxura wants to merge 2 commits into
bendlang:mainfrom
oxura:fix/f32-to-nat-wide-20261017

Conversation

@oxura

@oxura oxura commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #1636.

F32.to_nat went through U32, so it lost values that still fit a Nat. This keeps the existing small-value cast and combines high/low words only for larger inputs. The public function type is unchanged.

Exact F32 input Before, C and JS After, C and JS
4294967296 0 4294967296
4294967808 0 4294967808
281474959933440 0 281474959933440

The new regression also checks fractional truncation and the existing negative-input result. Ran it and num_kit on generated JS and native C; outputs match their golden lines. Repository gate: 54/54. Linux x86-64, Bun 1.3.13, clang 22.1.8. Mini-cluster/Metal/CUDA not run here. AI-assisted.

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.

F32.to_nat returns zero for representable Nats at and above 2^32

1 participant