Skip to content

Latest commit

 

History

History
116 lines (102 loc) · 2.76 KB

File metadata and controls

116 lines (102 loc) · 2.76 KB
title _cabs | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-standard-libraries
ms.tgt_pltfrm
ms.topic article
apiname
_cabs
apilocation
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-math-l1-1-0.dll
apitype DLLExport
f1_keywords
cabsl
_cabs
_cabsl
dev_langs
C++
helpviewer_keywords
cabs function
cabsl function
absolute values
_cabsl function
_cabs function
calculating absolute values
ms.assetid fea292ee-1a39-4a0a-b416-4a189346ff26
caps.latest.revision 13
author corob-msft
ms.author corob
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

_cabs

Calculates the absolute value of a complex number.

Syntax

double _cabs(   
   struct _complex z   
);  

Parameters

z
Complex number.

Return Value

_cabs returns the absolute value of its argument if successful. On overflow, _cabs returns HUGE_VAL and sets errno to ERANGE. You can change error handling with _matherr.

Remarks

The _cabs function calculates the absolute value of a complex number, which must be a structure of type _complex. The structure z is composed of a real component x and an imaginary component y. A call to _cabs produces a value equivalent to that of the expression sqrt( z.x * z.x + z.y * z.y ).

Requirements

Routine Required header
_cabs <math.h>

For more compatibility information, see Compatibility in the Introduction.

Example

// crt_cabs.c  
/* Using _cabs, this program calculates  
 * the absolute value of a complex number.  
 */  
#include <math.h>  
#include <stdio.h>  
  
int main( void )  
{  
   struct _complex number = { 3.0, 4.0 };  
   double d;  
  
   d = _cabs( number );  
   printf( "The absolute value of %f + %fi is %f\n",  
           number.x, number.y, d );  
}  
The absolute value of 3.000000 + 4.000000i is 5.000000  

See Also

Floating-Point Support
abs, labs, llabs, _abs64
fabs, fabsf, fabsl