www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Question on multiprecision types

reply "SteveGuo" <steveguo outlook.com> writes:
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.
Aug 05 2013
next sibling parent "SteveGuo" <steveguo outlook.com> writes:
Is there a plan to support those kind of types? If support, is it
a core language feature or library support?
Aug 05 2013
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
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-packe -unsigned-integers/ ) etc. Bye, bearophile
Aug 06 2013
prev sibling next sibling parent "SteveGuo" <steveguo outlook.com> writes:
 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-packe
-unsigned-integers/ 
 ) etc.

 Bye,
 bearophile

Thanks for replying:) I have to choose c++ on my project. Though I love D.
Aug 06 2013
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
SteveGuo:

 I have to choose c++ on my project.

Are std.bigint not efficient enough? Bye, bearophile
Aug 06 2013
prev sibling next sibling parent "SteveGuo" <steveguo outlook.com> writes:
 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
Aug 06 2013
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
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
Aug 06 2013
prev sibling next sibling parent "SteveGuo" <steveguo outlook.com> writes:
 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!
Aug 06 2013
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
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.
Aug 05 2013