Microsoft KB Archive/87702

= Microsoft Knowledge Base =

Excel: ATP Definition: IMABS
Last reviewed: April 17, 1996

Article ID: Q87702

The information in this article applies to:


 * Microsoft Excel for Windows 95, version 7.0
 * Microsoft Excel for Windows, versions 4.0, 5.0
 * Microsoft Excel for the Macintosh, versions 4.0, 5.0

SUMMARY
The versions of Microsoft Excel listed above provide a set of special analysis tools called the Analysis ToolPak. This article is part of a series of articles that provide information on the underlying formulas used in the Analysis ToolPak functions.

This articles covers IMABS, (Complex Number Absolute Value (Modulus)).

MORE INFORMATION
The C routine used by IMABS is:

typedef struct FCOMPLEX {float r,i;} fcomplex;
 * 1) include 

float Cabs(z) fcomplex z; {

float x,y,ans,temp; //Floating point variables x=fabs(z.r);        //x=absolute value of real coefficient y=fabs(z.i);        //y=absolute value of imaginary coefficient if (x == 0.0) ans=y; else if ( y == 0.0) ans=x; else if (x > y) { temp=y/x; ans=x*sqrt(1.0+temp*temp); } else { temp = x/y; ans=y*sqrt(1.0+temp*temp); }    return ans; }