Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Conversation

dnadlinger
Copy link
Contributor

This implements the (uint, uint) case using ulong arithmetic
and the (ulong, ulong) case using trial division. See Bugzilla
for an ulong implementation by David Bregman that does not
require a division. As the functions are expected to be
implemented as compiler intrinsics to make use of
architecture-specific primitives anyway, the simpler version
has been chosen to reduce the potential for bugs, even though
it is slower.

This implements the (uint, uint) case using ulong arithmetic
and the (ulong, ulong) case using trial division. See Bugzilla
for an ulong implementation by David Bregman that does not
require a division. As the functions are expected to be
implemented as compiler intrinsics to make use of
architecture-specific primitives anyway, the simpler version
has been chosen to reduce the potential for bugs, even though
it is slower.
@WalterBright
Copy link
Member

@WalterBright
Copy link
Member

Do the unit tests cover the 'broken' cases?

@WalterBright
Copy link
Member

BTW, when doing pull requests, please include a link to the bugzilla issue, and on the bugzilla issue please include a link to the PR. I have added them for this PR.

@dnadlinger
Copy link
Contributor Author

Yeah, sorry, I was creating this from the command line (the description is the commit message) and forgot to add the links. There is currently only one new test each, test(1UL << 32, 1UL << 32, 0, true), which failed before. I thought about adding a few other randomly generated ones, but didn't see a lot of gain in that with this new simple (and slow…) implementation.

@WalterBright
Copy link
Member

Auto-merge toggled on

WalterBright added a commit that referenced this pull request Jul 14, 2014
Fix issue 12958 - core.checkedint.mulu is broken.
@WalterBright WalterBright merged commit 7d2a2ef into dlang:master Jul 14, 2014
9rnsr pushed a commit to 9rnsr/druntime that referenced this pull request Jul 14, 2014
Fix issue 12958 - core.checkedint.mulu is broken.
@dnadlinger dnadlinger deleted the fix-checkedint-umul branch August 2, 2014 21:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants