More on semantics of opPow: return type

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Dec 7 16:41:05 PST 2009


Bill Baxter wrote:
> Negative exponent values are the only ones with an issue.  You can't
> even write square-root etc with pow using only integers.  The argument
> would have to be a float to even express that, so there is no issue.
> int^^float should be a float just like int/float is a float.

But -1^^0.5 is the imaginary constant! Something definitely doesn't add 
up. Are you sure you meant int^^float to be float? And what's the deal 
with the ongoing parallel exegesis with division? A division of reals 
doesn't result in a complex.

> So the only things left are those of the form  x^^-y.  or 1/(x^^y).  I
> don't see a reason to go any further than translating it to exactly
> that.
> And that's just division, so the %-like operator corresponding to that
> is just % itself ( or rather 1%(x^^y) )
> 
> I think Don was creating a tempest in a teapot.  I don't think any of
> his proposed alternatives besides treating it as integer division
> really make sense.  They are inconsistent with the rest of D, and so
> don't merit further consideration unless the behavior of 1/2 is also
> on the table.

To quote a living classic, when disagreeing with Don, you better have 
your ducks in a row.


Andrei



More information about the Digitalmars-d mailing list