Skip to main content
Cornell University
We gratefully acknowledge support from the Simons Foundation, member institutions, and all contributors. Donate
arxiv logo > cs > arXiv:1303.0328

Help | Advanced Search

arXiv logo
Cornell University Logo

quick links

  • Login
  • Help Pages
  • About

Computer Science > Data Structures and Algorithms

arXiv:1303.0328 (cs)
[Submitted on 2 Mar 2013 (v1), last revised 21 Aug 2016 (this version, v6)]

Title:Efficient long division via Montgomery multiply

Authors:Ernst W. Mayer
View a PDF of the paper titled Efficient long division via Montgomery multiply, by Ernst W. Mayer
View PDF
Abstract:We present a novel right-to-left long division algorithm based on the Montgomery modular multiply, consisting of separate highly efficient loops with simply carry structure for computing first the remainder (x mod q) and then the quotient floor(x/q). These loops are ideally suited for the case where x occupies many more machine words than the divide modulus q, and are strictly linear time in the "bitsize ratio" lg(x)/lg(q). For the paradigmatic performance test of multiword dividend and single 64-bit-word divisor, exploitation of the inherent data-parallelism of the algorithm effectively mitigates the long latency of hardware integer MUL operations, as a result of which we are able to achieve respective costs for remainder-only and full-DIV (remainder and quotient) of 6 and 12.5 cycles per dividend word on the Intel Core 2 implementation of the x86_64 architecture, in single-threaded execution mode. We further describe a simple "bit-doubling modular inversion" scheme, which allows the entire iterative computation of the mod-inverse required by the Montgomery multiply at arbitrarily large precision to be performed with cost less than that of a single Newtonian iteration performed at the full precision of the final result. We also show how the Montgomery-multiply-based powering can be efficiently used in Mersenne and Fermat-number trial factorization via direct computation of a modular inverse power of 2, without any need for explicit radix-mod scalings.
Comments: 23 pages; 8 tables v2: Tweak formatting, pagecount -= 2. v3: Fix incorrect powers of R in formulae [7] and [11] v4: Add Eldridge & Walter ref. v5: Clarify relation between Algos A/A',D and Hensel-div; clarify true-quotient mechanics; Add Haswell timings, refs to Agner Fog timings pdf and GMP asm-timings ref-page. v6: Remove stray +bw in MULL line of Algo D listing; add note re byte-LUT for qinv_0
Subjects: Data Structures and Algorithms (cs.DS)
MSC classes: 11Y16 (Primary), 68Q25, 68W40 (Secondary)
ACM classes: G.1.0; B.2.4; F.2.1
Cite as: arXiv:1303.0328 [cs.DS]
  (or arXiv:1303.0328v6 [cs.DS] for this version)
  https://doi.org/10.48550/arXiv.1303.0328
arXiv-issued DOI via DataCite

Submission history

From: Ernst W. Mayer [view email]
[v1] Sat, 2 Mar 2013 01:00:44 UTC (38 KB)
[v2] Tue, 5 Mar 2013 02:04:48 UTC (38 KB)
[v3] Thu, 7 Mar 2013 18:56:28 UTC (38 KB)
[v4] Mon, 22 Jul 2013 01:03:34 UTC (39 KB)
[v5] Mon, 2 Dec 2013 00:22:00 UTC (40 KB)
[v6] Sun, 21 Aug 2016 00:59:13 UTC (40 KB)
Full-text links:

Access Paper:

    View a PDF of the paper titled Efficient long division via Montgomery multiply, by Ernst W. Mayer
  • View PDF
  • TeX Source
  • Other Formats
view license
Current browse context:
cs.DS
< prev   |   next >
new | recent | 2013-03
Change to browse by:
cs

References & Citations

  • NASA ADS
  • Google Scholar
  • Semantic Scholar

DBLP - CS Bibliography

listing | bibtex
Ernst W. Mayer
export BibTeX citation Loading...

BibTeX formatted citation

×
Data provided by:

Bookmark

BibSonomy logo Reddit logo

Bibliographic and Citation Tools

Bibliographic Explorer (What is the Explorer?)
Connected Papers (What is Connected Papers?)
Litmaps (What is Litmaps?)
scite Smart Citations (What are Smart Citations?)

Code, Data and Media Associated with this Article

alphaXiv (What is alphaXiv?)
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub (What is DagsHub?)
Gotit.pub (What is GotitPub?)
Hugging Face (What is Huggingface?)
Papers with Code (What is Papers with Code?)
ScienceCast (What is ScienceCast?)

Demos

Replicate (What is Replicate?)
Hugging Face Spaces (What is Spaces?)
TXYZ.AI (What is TXYZ.AI?)

Recommenders and Search Tools

Influence Flower (What are Influence Flowers?)
CORE Recommender (What is CORE?)
  • Author
  • Venue
  • Institution
  • Topic

arXivLabs: experimental projects with community collaborators

arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.

Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

Which authors of this paper are endorsers? | Disable MathJax (What is MathJax?)
  • About
  • Help
  • contact arXivClick here to contact arXiv Contact
  • subscribe to arXiv mailingsClick here to subscribe Subscribe
  • Copyright
  • Privacy Policy
  • Web Accessibility Assistance
  • arXiv Operational Status
    Get status notifications via email or slack