Boost logo

Boost :

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:

> John,
> To be honest, I haven't had a chance to look at the Multiprecision library
> in
> 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
> integer-
> 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
> slower)."
> Boost.LargeInt is solely header and template based, and so is fully
> compatible
> 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
> two
> 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
> integer
> 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
> transparent.
> Please note that as all boost::large_int::large_int based types are
> themselves
> integer-like, Boost.Multiprecision may even be interoperable with them.
> If you
> are free to give it a try, I would welcome any input.
> Thanks,
> 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
>>> for
>>> your review and input, for potential inclusion into Boost v1.51.0 or
>>> later,
>>> as per the Boost Library Submission Process.
>> Michael,
>> How does this differ from Boost.Multiprecision currently being reviewed?
>> Thanks, John.
>> ______________________________**_________________
>> Unsubscribe & other changes:**
>> mailman/listinfo.cgi/boost<>

Boost list run by bdawes at, gregod at, cpdaniel at, john at