More on semantics of opPow: return type

Don nospam at nospam.com
Tue Dec 8 20:07:22 PST 2009


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.



More information about the Digitalmars-d mailing list