This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Change definition of complex::norm


> Wouldn't this be a little better:
> 
> double
> abs_3(double x, double y) {
> 
>   double abs_x = (x > 0. ? x : -x);
>   double abs_y = (y > 0. ? y : -y);
>   double s, min;
> 
>    if (abs_x > abs_y) {
>       s   = abs_x;
>       min = y;
>    } else {
>       s   = abs_y;
>       min = x;
>   }
>   if (s == 0.)
>     return s;
> 
>   min /= s;
> 
>   return s * sqrt( 1 + min * min);
> }

Absolutely.  I was trying to minimize the differences between the
two routines to highlight the result of a single difference.

Brad


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]