Subject: Re: [boost] Large Integer Library
From: Michael Tryhorn (mjtryhorn_at_[hidden])
Date: 2012-06-30 10:44:28
I have a few other features and benefits of the Boost.LargeInt library,
which may preempt some questions. I'm not sure how Boost.Multiprecision
compares on these specifically, but I thought they would help:
* All logical, arithmetic and bitwise operators in Boost.LargeInt
have constant, O(1) complexity; except for multiplication ('*'),
division ('/') and modulus ('%') which are O(n) on the number
of bits in the respective large_int type. Hence support for non
power-of-2 large_ints of 96bits, 160bits or otherwise may
be used to improve calculation performance.
* All boost::large_int::large_int based types are comparable
against long-type literal values. (These get an automatic
promotion to a boost::large_int equivalent to service said
* I've written it to work across multiple compilers, to hopefully
make this available to all. My reasoning being that if it can work
in GCC, MS Visual C++ and a rather old and somewhat temperamental
copy of Borland C++ Builder then it should work just about anywhere.
Michael J. Tryhorn
On 30 June 2012 13:23, Michael Tryhorn <mjtryhorn_at_[hidden]> wrote:
> To be honest, I haven't had a chance to look at the Multiprecision library
> depth. However, I have had a quick read through the documentation and have
> found a few points of difference, although there may be others:
> (All taken from
> * "Fixed at compile time values, for example 50 decimal digits"
> Boost.LargeInt is designed to stick-together two existing integer or
> like types, so although also being fixed at compile-time, it is fixed to a
> number of binary-bits rather than decimal digits.
> * "A header-only Boost license version is always available (if somewhat
> Boost.LargeInt is solely header and template based, and so is fully
> with, Boost License v1.0 without restriction. So, it performs as
> optimally as
> possible regardless of licensing requirements.
> * "Mixing arithmetic operations using types of different precision is
> strictly forbidden"
> Boost.LargeInt has been specifically designed to avoid such restrictions -
> where two integers of differing precision are compared the smaller of the
> is automatically promoted to be the same type as the larger. Them
> emphasis has
> always been upon being "as simple as possible". For example, for 128bit
> support, all one would need is the pre-existing boost::large_int::lint128_t
> type to take the initial value and any calculation, and a
> boost::large_int::large_int_cast<C>(value) to convert from 128bit to a
> built-in integer type, if needed.
> * "You have to be careful to cast the result of an expression to the actual
> number type when passing an expression to a template function"
> The results of all arithmetic operators in Boost.LargeInt are themselves
> boost::large_int::large_int based types, and so their use is fully
> Please note that as all boost::large_int::large_int based types are
> integer-like, Boost.Multiprecision may even be interoperable with them.
> If you
> are free to give it a try, I would welcome any input.
> Michael J. Tryhorn
> On 30 June 2012 12:52, John Maddock <boost.regex_at_[hidden]> wrote:
>> 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
>>> your review and input, for potential inclusion into Boost v1.51.0 or
>>> as per the Boost Library Submission Process.
>> How does this differ from Boost.Multiprecision currently being reviewed?
>> Thanks, John.
>> Unsubscribe & other changes: http://lists.boost.org/**
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk