More on semantics of opPow: return type

Bill Baxter wbaxter at gmail.com
Wed Dec 9 08:30:30 PST 2009


On Tue, Dec 8, 2009 at 8:07 PM, Don <nospam at nospam.com> wrote:
> Bill Baxter wrote:
>>
>> On Tue, Dec 8, 2009 at 10:18 AM, Bill Baxter <wbaxter at gmail.com> wrote:
>>>>
>>>> I agree. Then at least why not make the type of the exponent unsigned?
>>>> That
>>>> gives the type system a fighting chance (via e.g. value range
>>>> propagation).
>>>> Give Willy a chance!
>>>
>>> Honestly, I don't really understand this concern with range
>>> propagation.   Seems to me that allowing a negative exponent doesn't
>>> much expand the range, if a truncation rule is used.  The result is
>>> either undefined, 0 or 1.  The range is much greater with a
>>> non-negative exponent.  Could be undefined, zero, or most any negative
>>> or positive number.
>>
>> This was meant sincerely, by the way.  As in, I am ignorant about this
>> issue (the trouble with range propagation and negative exponents) and
>> would appreciate it if someone could explain it.
>>
>> --bb
>
> I'm bitterly opposed to making int^^negative int return 0. Doing that is
> making up a new operation. And it does really bad things. Why is 2^^-1 == 0,
> and not 1 ? If you're evaluating with the floating point unit, it will be 1
> when using "round up" mode.
> It's foul.

That doesn't really amount to much of an argument I can sink my teeth
into, but ok.  I think you're picking the greater of two evils, but
apparently I'm in the minority.

--bb



More information about the Digitalmars-d mailing list