JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.2: C++ User's Guide
search filter icon
search icon

Document Information

Preface

Part I C++ Compiler

1.  The C++ Compiler

2.  Using the C++ Compiler

3.  Using the C++ Compiler Options

Part II Writing C++ Programs

4.  Language Extensions

5.  Program Organization

6.  Creating and Using Templates

7.  Compiling Templates

8.  Exception Handling

9.  Improving Program Performance

10.  Building Multithreaded Programs

Part III Libraries

11.  Using Libraries

12.  Using The C++ Standard Library

13.  Using the Classic iostream Library

14.  Using the Complex Arithmetic Library

14.1 The Complex Library

14.1.1 Using the Complex Library

14.2 Type complex

14.2.1 Constructors of Class complex

14.2.2 Arithmetic Operators

14.3 Mathematical Functions

14.4 Error Handling

14.5 Input and Output

14.6 Mixed-Mode Arithmetic

14.7 Efficiency

14.8 Complex Man Pages

15.  Building Libraries

Part IV Appendixes

A.  C++ Compiler Options

B.  Pragmas

Glossary

Index

14.4 Error Handling

The complex library has these definitions for error handling:

extern int errno;
class c_exception {...};
int complex_error(c_exception&);

The external variable errno is the global error state from the C library. errno can take on the values listed in the standard header errno.h (see the man page perror(3)). No function sets errno to zero, but many functions set it to other values.

To determine whether a particular operation fails:

  1. Set errno to zero before the operation.

  2. Test the operation.

The function complex_error takes a reference to type c_exception and is called by the following complex arithmetic library functions:

The default version of complex_error returns zero. This return of zero means that the default error handling takes place. You can provide your own replacement function complex_error that performs other error handling. Error handling is described in the man page cplxerr(3CC4).

Default error handling is described in the man pages cplxtrig(3CC4) and cplxexp(3CC4) It is also summarized in the following table.

Complex Arithmetic Library Function
Default Error Handling Summary
exp
If overflow occurs, sets errno to ERANGE and returns a huge complex number.
log, log10
If the argument is zero, sets errno to EDOM and returns a huge complex number.
sinh, cosh
If the imaginary part of the argument causes overflow, returns a complex zero. If the real part causes overflow, returns a huge complex number. In either case, sets errno to ERANGE.