Numerical Operations

C++ is particularly powerful at engineering and scientific applications, which require intensive numerical calculations. There is the full range of mathematical functions inherited from C, now including versions that work with complex numbers. There are standard algorithms defined in <numeric>, which do full and partial sums of sequences. There is also the valarray class, which is optimized for high-performance applications and works like a mathematical vector.

Mathematical Functions: <cmath>

All the mathematical functions take double arguments and return double values. (In addition, C++ makes complex versions available.) Be careful with functions like sqrt(), log(), and pow() that are not defined for all values of x; this ...

Get C++ By Example: UnderC Learning Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.