Double-Word Integers; Complex Numbers - Red Hat ENTERPRISE LINUX 4 Manual

Hide thumbs Also See for ENTERPRISE LINUX 4:
Table of Contents

Advertisement

140
Chapter 6. Extensions to the C Language Family
has the value of
if that is nonzero; otherwise, the value of
.
x
y
This example is perfectly equivalent to
x ? x : y
In this simple case, the ability to omit the middle operand is not especially useful. When it becomes
useful is when the first operand does, or may (if it is a macro argument), contain a side effect. Then
repeating the operand in the middle would perform the side effect twice. Omitting the middle operand
uses the value already computed without the undesirable effects of recomputing it.

6.9. Double-Word Integers

ISO C99 supports data types for integers that are at least 64 bits wide, and as an extension GCC sup-
ports them in C89 mode and in C++. Simply write
for a signed integer, or
long long int
unsigned
for an unsigned integer. To make an integer constant of type
, add
long long int
long long int
the suffix
to the integer. To make an integer constant of type
, add the
LL
unsigned long long int
suffix
to the integer.
ULL
You can use these types in arithmetic like any other integer types. Addition, subtraction, and bitwise
boolean operations on these types are open-coded on all types of machines. Multiplication is open-
coded if the machine supports fullword-to-doubleword a widening multiply instruction. Division and
shifts are open-coded only on machines that provide special support. The operations that are not open-
coded use special library routines that come with GCC.
There may be pitfalls when you use
types for function arguments, unless you declare
long long
function prototypes. If a function expects type
for its argument, and you pass a value of type
int
, confusion will result because the caller and the subroutine will disagree about the
long long int
number of bytes for the argument. Likewise, if the function expects
and you pass
long long int
. The best way to avoid such problems is to use prototypes.
int

6.10. Complex Numbers

ISO C99 supports complex floating data types, and as an extension GCC supports them in C89 mode
and in C++, and supports complex integer data types which are not part of ISO C99. You can declare
complex types using the keyword
. As an extension, the older GNU keyword
_Complex
__complex__
is also supported.
For example,
declares
as a variable whose real part and imaginary part are
_Complex double x;
x
both of type
.
declares
to have real and imaginary parts of type
double
_Complex short int y;
y
; this is not likely to be useful, but it shows that the set of complex types is complete.
short int
To write a constant with a complex data type, use the suffix
or
(either one; they are equivalent).
i
j
For example,
has type
and
has type
. Such a constant
2.5fi
_Complex float
3i
_Complex int
always has a pure imaginary value, but you can form any complex value you like by adding one to a
real constant. This is a GNU extension; if you have an ISO C99 conforming C library (such as GNU
libc), and want to construct complex constants of floating type, you should include
complex.h
and use the macros
or
instead.
I
_Complex_I
To extract the real part of a complex-valued expression
, write
. Likewise, use
exp
__real__
exp
to extract the imaginary part. This is a GNU extension; for values of floating type, you
__imag__
should use the ISO C99 functions
,
,
,
,
and
, declared
crealf
creal
creall
cimagf
cimag
cimagl
in
and also provided as built-in functions by GCC.
complex.h

Advertisement

Table of Contents
loading

Table of Contents