Re: math operators

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jon wrote:

>> Lucius Hilley wrote:
>>
>> POWER
>> I would love to see power(4, 5) become 4^5.
>> I know that we wouldn't be able to get read of power()
>
> YES! i prefer "^" but another alternative is "**" (like Ruby)


I never saw a program, that uses '++' as alternative for '*', or '--' as
alternative for '/'. I know, that there are some programs that use '**'
as alternative for '^', but I don't see any reason, why that should be
useful.


The following text explains, why I prefer 'power(x,y)' to 'x^y':

Math operations of the same priority, such as 7+5+1, are normally
evaluated from left to right, if no parentheses are used. OK.

And how about the power operator? What is the result of
   2^3^2  ?

Mathematically, evaluation is right to left for the power operator! So
   2^3^2 = 2^(3^2) = 2^9 = 512.

But there seems to be a kind of "industry standard", that says that such
expressions should be calculated from left to right. That means:
   2^3^2 = (2^3)^2 = 8^2 = 64

For example all PowerBASIC versions that I know, and AFAIK also Visual
Basic calculates such expressions this way.
I have a pocket calculator that doesn't perform it's calculation until
the entire expression has been entered (very nice, BTW).
It returns 64 for 2^3^2, too (which is false, strictly mathematically
speaking).

IMHO, this situation is very strange.
And Euphoria completly avoids this dilemma by using a 'power()' function,
instead of a power operator!!! I was very pleased, when I noticed that.

So beside Euphorias obvious elegance, it has some "hidden elegance",
that cannot be seen at the first glance.


>> BITWISE OPERATORs
>> compare() become ==
>> and_bits() become &&
>> or_bits() become ||
>>
>> or at least see them used as operators. Such as:
>>   if (int1 and_bits int2) then
>>     if (int2 or_bits int2) then
>>     end if
>>   end if
>> But that wouldn't be backwards compatible. :(
>
> again, yes!

No, please!
I'm happy that Euphoria code is very good readable ATM.
I would not be happy to see anything that makes it less readable.

<snip>

Regards,
   Juergen

-- 
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu