As a Mathematician I would like:

renoX renosky at free.fr
Sat Jun 30 08:49:31 PDT 2007


Derek Parnell a écrit :
> 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.

And?
Some compiler inline function calls which is a nice optimisation in this 
case.

renoX

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



More information about the Digitalmars-d mailing list