Skip to content

Don't use ZeroWrapLimited. Use unlimited version instead.#410

Merged
tompng merged 1 commit intoruby:masterfrom
tompng:remove_wraplimited
Aug 22, 2025
Merged

Don't use ZeroWrapLimited. Use unlimited version instead.#410
tompng merged 1 commit intoruby:masterfrom
tompng:remove_wraplimited

Conversation

@tompng
Copy link
Member

@tompng tompng commented Aug 22, 2025

Auto limit allocation is not so good.
After several refactoring and bug fixes, ZeroWrapLimited turned out to be useless in most cases.
It allocates with extra Max(extra_sub_prec, extra_rounding_prec, extra_div_prec, extra_sqrt_prec, ...) DECDIGs. This value 2 is hardcoded.
In a few case that ZeroWrapLimited is really needed, explicitly calculate precision is enough.

// Before
NewZeroWrapLimited(1, mx + extra); // Be sure extra <= 2*BASE_FIG because NewZeroWrapLimited hardcodes 2

// After
if (prec == 0 && prec_limit) mx = prec_limit;
NewZeroWrap(1, mx + extra); // extra can be any value

Remaining NewZeroWrapLimited and NewOneNolimit is only used in sqrt and will be removed in #381

ZeroWrapLimited turned out to be useless in most case.
In a few case that ZeroWrapLimited is needed, explicitly calculate precision is enough.
@tompng tompng force-pushed the remove_wraplimited branch from 8c87a9e to a23ea32 Compare August 22, 2025 12:39
@tompng tompng merged commit 73c1caf into ruby:master Aug 22, 2025
79 checks passed
@tompng tompng deleted the remove_wraplimited branch August 22, 2025 12:59
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