Repository navigation
fix(ar2): compute the random template index in double precision (#40) - #77
Merged
Merged
Conversation
RAND_MAX + 1.0F converted 2147483647 to float (-Wimplicit-const-int-float-conversion). A double holds RAND_MAX + 1 exactly, and j * rand() no longer loses precision. k stays in [0, j-1]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR |
PR Summary by QodoCompute AR2 random template indices in double precision
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
kalwalt
added a commit
to webarkit/jsartoolkitNFT
that referenced
this pull request
Oct 6, 2026
- emscripten/WebARKitLib: b2d6166 on WebARKitLib dev, which adds webarkit/WebARKitLib#77 (#40: random template index computed in double precision in AR2/selectTemplate.c, fixing the -Wimplicit-const-int-float-conversion warning) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts); vitest 182 passed / 6 skipped, node 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
Merged
kalwalt
added a commit
to webarkit/jsartoolkitNFT
that referenced
this pull request
Oct 7, 2026
* refactor: use the NFT helpers from WebARKitLib (#453) trackingMod, trackingMod2d, trackingSub, markerDecompress and NFTMarkerState moved to WebARKitLib (webarkit/WebARKitLib#75, #76) under WebARKit/WebARKitTrackers/WebARKitNFT. - tools/makem.js: take those sources from WebARKitLib and add its include directory - bindings (JS and Python): include <WebARKitTrackers/WebARKitNFT/...> - python-bindings/setup.py: new source and include paths - remove the copies from emscripten/ - bump the WebARKitLib submodule to feat/issue-75-webarkit-nft Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: report a failed .zft decompression through onError decompressMarkers() now returns -1 for a missing or malformed archive instead of exiting. The decompressZFT bindings returned 1 regardless, so loadZFT read temporary files that were never written and threw ENOENT before any callback ran. The bindings now return -1 on failure and loadZFT calls onError(prefix + ".zft"). Reported by Qodo on #687. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: free the .zft archive from MEMFS once decompressed loadZFT kept /markerNFT_N.zft in the Emscripten filesystem for the whole session; the old C-side remove() built the name without the dot, so it never deleted it either. Suggested by Qodo on #687. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump WebARKitLib to dev and rebuild build/ and dist/ (#453) - emscripten/WebARKitLib: dfe8570 on WebARKitLib dev, the squash merge of webarkit/WebARKitLib#76 (same tree as the 480fdb9 used so far) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts) The earlier commits of this PR (0cff312, 3543c45, 00cf36e) changed C/C++, JS and TS sources without committing the rebuilt build/ and dist/; this commit brings them up to date with those changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump WebARKitLib to b2d6166 and rebuild build/ and dist/ - emscripten/WebARKitLib: b2d6166 on WebARKitLib dev, which adds webarkit/WebARKitLib#77 (#40: random template index computed in double precision in AR2/selectTemplate.c, fixing the -Wimplicit-const-int-float-conversion warning) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts); vitest 182 passed / 6 skipped, node 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump WebARKitLib to b5e4770 and rebuild build/ and dist/ - emscripten/WebARKitLib: b5e4770 on WebARKitLib dev, which adds webarkit/WebARKitLib#80 (review fixes before 0.10.0: capped .zft decompression, trackingInitMain null check, explicit #error for AR2_CAPABLE_ADAPTIVE_TEMPLATE) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts); vitest 182 passed / 6 skipped, node 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: pin WebARKitLib to the 0.10.0 release tag Move emscripten/WebARKitLib from b5e4770 (dev) to 4fd3034, the merge commit on master tagged 0.10.0, as the 0.9.0 pin pointed at master. Both commits have the same tree, so build/ and dist/ are unchanged and need no rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #40.
Summary
lib/SRC/AR2/selectTemplate.c:279picks a random candidate index:RAND_MAX + 1.0Fconverted 2147483647 to afloat, which cannot hold it exactly (-Wimplicit-const-int-float-conversion). AdoublerepresentsRAND_MAX + 1exactly, andj * rand()no longer loses precision in single-precision float.rand() / (RAND_MAX + 1.0)stays below 1, sokis still in[0, j-1].lib/SRC/**): one line, as proposed in #40.Test plan
emcc -WallonselectTemplate.c(emsdk 4.0.17): the warning is goneWebARKitNFTbuilds with Emscripten 4.0.17webarkit_nft_test12/12,webarkit_test28/28🤖 Generated with Claude Code