As a Mathematician I would like:

Derek Parnell derek at psych.ward
Fri Jun 29 20:51:06 PDT 2007


On Fri, 29 Jun 2007 21:10:15 -0500, Stephen Montgomery-Smith wrote:

> Don Clugston wrote:
>> Stephen Montgomery-Smith wrote:
>>> If I had two changes I would make to the C programming language, it is
>>>
>>> 1. Put in an exponentiation operator, a^b or a**b, so that 2**3 is 8. 
>>> For a numerics programmer this would be really useful. This is one way 
>>> that Fortran really scores over C. I know that there is the pow 
>>> function in C, but it always treats the power as a float or double, 
>>> where if the power is an integer it should really work differently.
>> Actually pow() does work differently for integers.
>>> Also the optimization should be able to do clever things with a^2 
>>> (i.e. write it as inline code a*a).
> 
> If I write a = pow(x,5.0), would a typical modern compiler produce 
> inline code something like
> b=x*x;
> a=b*b*x?
> If this is so, that is really neat!!!

I hope not! That is definitely a call to a function.

However a = x ^^ 5 (not 5.0) could be inlined as you suggested (if "^^" is
interpreted as a 'raise to the power of' operator.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list