Add toDouble for the FastInt family - #6592
Closed
meshinspector-agent[bot] wants to merge 1 commit into
Closed
Conversation
The pre-filters that reject a case in double before evaluating it exactly need a bignum-to-double conversion, which the family lacked: MSVC's std::_Signed128 has no such operator at all. It is correctly rounded, and deliberately platform-independent rather than deferring to the built-in __int128_t conversion, since the stated error bound is what makes those rejections safe.
This was referenced Aug 14, 2026
Contributor
Author
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.
First of the three increments that restore the shadow filter's
doublepre-filters. They were dropped in the port because theFastIntfamily has no conversion todouble— on MSVCFastInt128isstd::_Signed128, which has no such operator at all — so every shadow test is currently exact.What changed
toDouble( FastInt128 )andtoDouble( const FastInt<nBits> & ), both over one shareddetail::doubleFromWords.2^53, relative error below2^-53above it,±infpastDBL_MAX. The bound is documented at the function, since a pre-filter that rejects a case indoubleis only safe against a stated conversion error.__int128_t → doubleon gcc/clang: the same code on every platform, so the filter's numbers cannot diverge between MSVC and the rest.MRFastInt.h/MRFastInt128.hno longer claim the conversion is missing.Correct rounding comes from a single
std::uint64_t → double(itself correctly rounded) of the top 64 significant bits, with everything below folded into a sticky lowest bit — so a tie is told from a value just above it without a second rounding.No caller yet: increments 2 and 3 consume it.
Verification
MRTestin Release with g++-12 in theubuntu22image, mirroringbuild-test-ubuntu-x64.yml(prebuilt thirdparty linked, Python bindings off) — clean.MRTest: 354/354 pass, includingMRAlphaShapeTestsand theInSphere/SoS predicate tests.MRFastIntTests.cpp, against that file's existingRefIntoracle rather than any code under test:2^53at every width, and+0for zero;std::nextafterneighbour is closer — and within the documented2^-53;2^53(round-to-even both ways) and the sticky-bit tie at2^64 + 2^11, which only a correct tail test gets right;double;±infpastDBL_MAX— reachable only through a product, since a 1024-bit value maxes at2^1023 < DBL_MAX, soFastInt<2048>andmax1024 * max1024cover it.std::_Signed128path (no Windows box on this runner) — sharing one word-based implementation is precisely what makes that path the same code; CI covers it. No UI surface and nothing to drive in the viewer: a header-only numeric addition with no caller until the next increment, so behaviour is unchanged at runtime.CI label: none.
build-test-distribute.ymlis gated onpull_request: branches: [ master ], so a PR based onalpha-shape-triangle-shadowgets no checks by design; the numbers come from the branch run after the squash-merge.