std.rational?
ilya-stromberg
ilya-stromberg-2009 at yandex.ru
Mon Sep 30 23:26:49 PDT 2013
On Monday, 30 September 2013 at 18:01:29 UTC, Joseph Rushton
Wakeling wrote:
> On 30/09/13 19:39, Joseph Rushton Wakeling wrote:
>> ... although the new gcf will fail if passed immutable/const
>> BigInts.
>
> On this note:
> http://d.puremagic.com/issues/show_bug.cgi?id=11148
>
> I had to tweak CommonInteger to handle immutable/const BigInts,
> and I'm not sure whether this was done correctly, although it
> seems to be largely in line with how CommonType works.
Note that denumerator must be allways positive (> 0).
But numerator can be positive, zero or negative, and can be
bigger than denumerator.
It means that we can use different types for numerator and
denumerator:
Rational!(int, uint) r;
Rational!(long, ulong) r;
Rational!(long, uint) r;
Rational!(BigInt, BigUint) r;
We have BigUint in Phobos, but it's private.
Also, if we need only positive rationals, we can use unsigned
types for numerator:
Rational!(uint, uint) r;
Rational!(ulong, ulong) r;
Rational!(ulong, uint) r;
Rational!(BigUint, BigUint) r;
More information about the Digitalmars-d
mailing list