Complex Numbers(_Complex)

Complex Numbers

ISO C99 supports complex floating data types, and as an extension GCCsupports them in C89 mode and in C++, and supports complex integer datatypes which are not part of ISO C99. You can declare complex typesusing the keyword _Complex. As an extension, the older GNUkeyword __complex__ is also supported.

For example, `_Complex double x;' declares x as avariable whose real part and imaginary part are both of typedouble. `_Complex short int y;' declares y tohave real and imaginary parts of type short int; this is notlikely to be useful, but it shows that the set of complex types iscomplete.

To write a constant with a complex data type, use the suffix `i' or`j' (either one; they are equivalent). For example, 2.5fihas type _Complex float and 3i has type_Complex int. Such a constant always has a pure imaginaryvalue, but you can form any complex value you like by adding one to areal constant. This is a GNU extension; if you have an ISO C99conforming C library (such as GNU libc), and want to construct complexconstants of floating type, you should include <complex.h> anduse the macros I or _Complex_I instead.

To extract the real part of a complex-valued expression exp, write__real__ exp. Likewise, use __imag__ toextract the imaginary part. This is a GNU extension; for values offloating type, you should use the ISO C99 functions crealf,creal, creall, cimagf, cimag andcimagl, declared in <complex.h> and also provided asbuilt-in functions by GCC.

The operator `~' performs complex conjugation when used on a valuewith a complex type. This is a GNU extension; for values offloating type, you should use the ISO C99 functions conjf,conj and conjl, declared in <complex.h> and alsoprovided as built-in functions by GCC.

GCC can allocate complex automatic variables in a noncontiguousfashion; it's even possible for the real part to be in a register whilethe imaginary part is on the stack (or vice-versa). Only the DWARF2debug info format can represent this, so use of DWARF2 is recommended. If you are using the stabs debug info format, GCC describes a noncontiguouscomplex variable as if it were two separate variables of noncomplex type. If the variable's actual name is foo, the two fictitiousvariables are named foo$real and foo$imag. You canexamine and set these two fictitious variables with your debugger.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值