More on semantics of opPow: return type
Simen kjaeraas
simen.kjaras at gmail.com
Wed Dec 9 01:19:09 PST 2009
On Wed, 09 Dec 2009 05:28:23 +0100, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Don 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.
>
> Awesome! Don please please require the exponent to be of unsigned type
> :o).
>
> Andrei
Yeah. Makes no sense allowing it to be signed.
--
Simen
More information about the Digitalmars-d
mailing list