Thread overview
Question on multiprecision types
Aug 06, 2013
SteveGuo
Aug 06, 2013
SteveGuo
Aug 06, 2013
bearophile
Aug 06, 2013
SteveGuo
Aug 06, 2013
bearophile
Aug 06, 2013
SteveGuo
Aug 06, 2013
bearophile
Aug 06, 2013
SteveGuo
Aug 10, 2013
H. S. Teoh
August 06, 2013
Does D support types like cpp_int or cpp_rational in
boost::multiprecision? D is designed directly mapped to hardware
for speed reason. But in some cases, we do need types like
cpp_int or cpp_rational support.
August 06, 2013
Is there a plan to support those kind of types? If support, is it
a core language feature or library support?

August 06, 2013
SteveGuo:

> Is there a plan to support those kind of types? If support,
> is it a core language feature or library support?

That will not have a core language support, beside perhaps cent/ucent. At the moment there are no plans for library support, but eventually in some years fixed-size multi-precision integers will be good to have in Phobos, just like several other things, like nD packed arrays (http://pempek.net/articles/2013/08/03/packedarray-random-access-array-tightly-packed-unsigned-integers/ ) etc.

Bye,
bearophile
August 06, 2013
> That will not have a core language support, beside perhaps cent/ucent. At the moment there are no plans for library support, but eventually in some years fixed-size multi-precision integers will be good to have in Phobos, just like several other things, like nD packed arrays (http://pempek.net/articles/2013/08/03/packedarray-random-access-array-tightly-packed-unsigned-integers/ ) etc.
>
> Bye,
> bearophile

Thanks for replying:) I have to choose c++ on my project. Though I love D.

August 06, 2013
SteveGuo:

> I have to choose c++ on my project.

Are std.bigint not efficient enough?

Bye,
bearophile
August 06, 2013
> Are std.bigint not efficient enough?
>
> Bye,
> bearophile

std.bigint, I think it's an equevelent of cpp_int, but My project has to use cpp_rational

August 06, 2013
SteveGuo:

> std.bigint, I think it's an equevelent of cpp_int, but My project has to use cpp_rational

A rational was implemented in D by several persons, it's easy. Of the few problems is implement an efficient GCD among bigints (that sooner or later will be needed in std.bigint).

Bye,
bearophile
August 06, 2013
> A rational was implemented in D by several persons, it's easy. Of the few problems is implement an efficient GCD among bigints (that sooner or later will be needed in std.bigint).
>
> Bye,
> bearophile

That's great!

August 10, 2013
On Tue, Aug 06, 2013 at 07:43:29AM +0200, SteveGuo wrote:
> Does D support types like cpp_int or cpp_rational in boost::multiprecision? D is designed directly mapped to hardware for speed reason. But in some cases, we do need types like cpp_int or cpp_rational support.

There's std.bigint, but I don't know whether there's a rational library yet. But you can probably use BigInt to implement one.


T

-- 
Help a man when he is in trouble and he will remember you when he is in trouble again.