Boost logo

Boost :

Subject: [boost] Large Integer Library
From: Michael Tryhorn (mjtryhorn_at_[hidden])
Date: 2012-06-30 07:06:39


Dear Boosters,

I have written a Boost-compatible library for the representation and
manipulation of integers of large or arbitrary size (including 128bit and
above). I would like to make a preliminary submission of this library for
your review and input, for potential inclusion into Boost v1.51.0 or later,
as per the Boost Library Submission Process.

The library and all its files are publicly available on github, at:

http://github.com/mjtryhorn/Boost.LargeInt

A tagged .zip of these files (v1.0.0) is available for download at:

http://github.com/mjtryhorn/Boost.LargeInt/tags

This library has been written for strict conformance to C++03 and the Boost
coding guidelines. This library is also header-only, and as such may be
directly merged into existing Boost installations without the need for
recompilation.

All files are distributed under the Boost Software License, Version 1.0.

Now a quick explanation of why I've written this library and what it does:

I have found myself on several occasions to be working with unsigned 64bit
numbers, mostly for the sizes of files or C++ collections. Where I had a
need
to perform a calculation upon those numbers, there was often the possibility
of overflow. 128bit integers would have been an appropriate fix, but these
are either entirely unavailable, non-portable, or in a library which I
preferred not to use either due to its complexity or incompatible licensing.
Floating-point arithmetic is also a means around the problem, but is
inherently inaccurate.

I decided to fix this problem once-and-for-all by writing a new integer
arithmetic library, making judicious use of C++'s template-metaprogramming
and Boost to make my solution both as simple and as transparent as possible.

Now, what started out as 128bit integers for my own use has grown into a
fully-
functional library which has the ability to compose any two integer or
integer-
like types into a new, larger, signed or unsigned integer type, including
all
the standard integral operators and a number of utility functions to support
them. Thus, Boost.LargeInt supports not only signed and unsigned 128bit
integer arithmetic but 24bit, 64bit, 160bit, 192bit, 256bit, 512bit and
more.

Boost.LargeInt is compatible and has been tested with the following
compilers and platforms:

    GNU GCC 4.6.1, 4.6.2 (Linux, Ubuntu 11.10 (64bit) & openSUSE 12.1
(32bit))
    Borland C++ 5.6.4 (Windows XP SP3, Borland C++ Builder 6)
    Microsoft Visual C++ 2010 (Windows XP SP3, Microsoft Visual Studio 2010)

(I have also tried to add compatibility for Microsoft Visual C++ 6, but
unfortunately this compiler's support for template-metaprogramming is
insufficient and the tests for Boost.LargeInt fail to compile.)

Documentation is included in BoostBook format (.qbk), but a pre-compiled
version is available alongside the library code itself for your convenience.

Please, if you have the time, download this library and give it a try. Any
comments, or information upon its compatibility (or lack thereof) with
compilers which are or are not listed would be greatly appreciated.

If no-one has any comments (I think that unlikely ;-) ), then I shall
resubmit
this library for formal review.

Thanks,

Michael J. Tryhorn


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk