More on semantics of opPow: return type

Bill Baxter wbaxter at gmail.com
Mon Dec 7 16:51:44 PST 2009


On Mon, Dec 7, 2009 at 4:41 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> 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.

Don already covered that.  Floats have nan, so that would be a nan.

>> 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.

Doin' my best here.

--bb



More information about the Digitalmars-d mailing list