Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      cabsf, cabs, cabsl

      From cppreference.com
      <c‎ |numeric‎ |complex
       
       
       
      Complex number arithmetic
      Types and the imaginary constant
      (C99)
      (C99)    
      (C11)
      (C99)
      Manipulation
      (C99)
      (C99)
      (C99)
      cabs
      (C99)
      (C99)
      (C99)
      Power and exponential functions
      (C99)
      (C99)
      (C99)
      (C99)
      Trigonometric functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      Hyperbolic functions
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
      (C99)
       
      Defined in header<complex.h>
      float       cabsf(floatcomplex z);
      (1)(since C99)
      double      cabs(doublecomplex z);
      (2)(since C99)
      longdouble cabsl(longdoublecomplex z);
      (3)(since C99)
      Defined in header<tgmath.h>
      #define fabs( z )
      (4)(since C99)
      1-3) Computes the complex absolute value (also known as norm, modulus, or magnitude) ofz.
      4) Type-generic macro: ifz has typelongdoublecomplex orlongdoubleimaginary,cabsl is called. Ifz has typefloatcomplex orfloatimaginary,cabsf is called. Ifz has typedoublecomplex ordoubleimaginary,cabs is called. For real and integer types, the corresponding version offabs is called.

      Contents

      [edit]Parameters

      z - complex argument

      [edit]Return value

      If no errors occur, returns the absolute value (norm, magnitude) ofz.

      Errors and special cases are handled as if the function is implemented ashypot(creal(z),cimag(z))

      [edit]Example

      Run this code
      #include <stdio.h>#include <complex.h> int main(void){doublecomplex z=1.0+1.0*I;printf("%.1f%+.1fi cartesian is rho=%f theta=%f polar\n",creal(z),cimag(z), cabs(z),carg(z));}

      Output:

      1.0+1.0i cartesian is rho=1.414214 theta=0.785398 polar

      [edit]References

      • C11 standard (ISO/IEC 9899:2011):
      • 7.3.8.1 The cabs functions (p: 195)
      • 7.25 Type-generic math <tgmath.h> (p: 373-375)
      • G.7 Type-generic math <tgmath.h> (p: 545)
      • C99 standard (ISO/IEC 9899:1999):
      • 7.3.8.1 The cabs functions (p: 177)
      • 7.22 Type-generic math <tgmath.h> (p: 335-337)
      • G.7 Type-generic math <tgmath.h> (p: 480)

      [edit]See also

      (C99)(C99)(C99)
      computes the phase angle of a complex number
      (function)[edit]
      computes absolute value of an integral value (\(\small{|x|}\)|x|)
      (function)[edit]
      (C99)(C99)
      computes absolute value of a floating-point value (\(\small{|x|}\)|x|)
      (function)[edit]
      (C99)(C99)(C99)
      computes square root of the sum of the squares of two given numbers (\(\scriptsize{\sqrt{x^2+y^2} }\)x2
      +y2
      )
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/cabs&oldid=77459"

      [8]ページ先頭

      ©2009-2025 Movatter.jp