std.rational?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Wed Oct 2 02:30:21 PDT 2013


On 01/10/13 16:49, H. S. Teoh wrote:
> This is needlessly complex. We should just use signed types for both
> numerator and denominator, and handle sign by a canonicalization
> operation (canonicalization is already needed for reducing the fraction
> to its lowest terms anyway, and if gcd is implemented appropriately, it
> will return a number of appropriate sign to cancel out the negative sign
> in the denominator (or numerator), so this doesn't even need to be a
> separate check).

That's how it's done.  But your remark made me realize that correction of the 
signs is not checked in the unittests, so I've added a couple such checks. :-)



More information about the Digitalmars-d mailing list