noun: /lib/twoc two's-complement jets (scalar + Lagoon %int2 arrays)#1047
Open
sigilante wants to merge 1 commit into
Open
noun: /lib/twoc two's-complement jets (scalar + Lagoon %int2 arrays)#1047sigilante wants to merge 1 commit into
sigilante wants to merge 1 commit into
Conversation
This was referenced Jun 29, 2026
Bit-exact C jets for the numerics /lib/twoc two's-complement integer library, under the non chapter alongside math/lagoon/unum. No vendored library: the arithmetic is plain integer C plus GNU MP (already linked into pkg/noun). jets/i/twoc.c -- one %twid core (the width-keyed door where /lib/twoc keeps its logic; the bloq-keyed facade re-exports its gates, so this fires for both). Reads wid from the door sample (gate axis 30) and dispatches: native c3_d for wid<=64, __int128 for <=128, GMP (u3r_mp/u3i_mp) for >128. Arms: add sub neg mul div rem pow abs gth lth lte gte. Declines to Hoon on out-of-width operands and zero divisors. Kernels shared via jets/i/twoc.h. jets/i/lagoon.c -- Lagoon element-wise array jets (add/sub/mul/div/mod-rays) gain a %int2 case beside %i754, looping native two's-complement per lane over the ray byte buffer (one C pass vs the super-linear Hoon bit-packing loop). Registered twid under non in the 135/136/137 dashboards. Fires bit-exact on a hoon-135 fakezod (scalar verified two ways: sentinel + timing; %int2 array add ~310,000x over interpreted at 200k lanes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sigilante
force-pushed
the
sigilante/twoc-jets
branch
from
June 29, 2026 15:44
fe0cd7d to
4375784
Compare
Collaborator
Author
|
Coordination note: #1057 rewrites the lagoon.c validation layer and several kernels on develop, and every wrapper this PR's %int2 additions hook into changes shape there ( 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bit-exact C jets for the numerics
/lib/twoctwo's-complement integer library, under thenonchapter alongsidemath/lagoon/unum. Hoon side: urbit/numerics#66.No vendored library — the arithmetic is plain integer C plus GNU MP (already linked into
pkg/noun).Changes
jets/i/twoc.c— one%twidcore (the width-keyed door where/lib/twockeeps its logic; the bloq-keyed facade re-exports its gates, so this fires for both call paths). Readswidfrom the door sample (gate axis 30) and dispatches: nativec3_dforwid<=64,__int128for<=128, GMP (u3r_mp/u3i_mp) for>128. Arms:add sub neg mul div rem pow abs gth lth lte gte. Declines to Hoon on out-of-width operands and zero divisors.jets/i/twoc.h— shared two's-complement kernels (used bytwoc.candlagoon.c).jets/i/lagoon.c— the element-wise array jets (add/sub/mul/div/mod-rays) gain a%int2case beside%i754, looping native two's-complement per lane over the ray byte buffer (one C pass vs the super-linear Hoon bit-packing loop).jets/w.h,q.h—u3wi_twid_*/u3qi_twid_*declarations.build.zig— addjets/i/twoc.c(no newlinkLibrary; GMP already linked).jets/{135,136,137}/tree.c— registertwidundernon(sibling oflagoon).Validation
twid-direct and thetwocfacade; timing toggle ~3.3×).%int2array ops verified jet == Hoon for all five; ~310,000× over interpreted at 200k lanes.Built and fired on the 32-bit runtime.
🤖 Generated with Claude Code