std.rational?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Oct 1 01:02:01 PDT 2013


On 01/10/13 08:26, ilya-stromberg wrote:
> 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:

Seems an overcomplication for me, and it doesn't save you from denominator == 0, 
so it doesn't get you out of any checks.

> We have BigUint in Phobos, but it's private.

Interesting.  Any particular reason?  (I suppose the nature of BigInt is that 
you don't need to worry about signed/unsigned distinction because there is no 
range limit.)

> Also, if we need only positive rationals, we can use unsigned types for numerator:

Yes, but you can already get that as is by Rational!(UnsignedTypeOfChoice) :-)



More information about the Digitalmars-d mailing list