cmath
i'm confused about "cmath"
what's the main points cmath?
cmath is a header that contains a lot of useful math functions.
You can do a lot of calculations without using the cmath library.
For example:
1 2
|
int x = 5;
int y = x * x; // y is x squared
|
but what if we want something like this:
1 2
|
int x = 25;
int y = √x; // y should be the square root of x
|
That doesn't work, as there is no operator for square root. Instead, we use a library function:
1 2
|
double x = 25.0;
double y = sqrt(x);
|
And the same applies for many other functions, some common, such as sin or log, and others maybe less obvious, but still useful in their own way.
Topic archived. No new replies allowed.