The <QtMath> header file provides various math functions.

These functions are partly convenience definitions for basic math operations not available in the C or Standard Template Libraries.

The header also ensures some constants specified in POSIX, but not present in C++ standards (so absent from <math.h> on some platforms), are defined:

M_E

The base of the natural logarithms, e = exp(1)

Returns the arccosine of `v`

as an angle in radians. Arccosine is the inverse operation of cosine.

See also

`qAtan()`

`qAsin()`

`qCos()`

Returns the arcsine of `v`

as an angle in radians. Arcsine is the inverse operation of sine.

See also

`qSin()`

`qAtan()`

`qAcos()`

Returns the arctangent of `v`

as an angle in radians. Arctangent is the inverse operation of tangent.

See also

`qTan()`

`qAcos()`

`qAsin()`

Returns the arctangent of a point specified by the coordinates `y`

and `x`

. This function will return the angle (argument) of that point.

See also

`qAtan()`

`qHypot()`

Returns the ceiling of the value `v`

.

The ceiling is the smallest integer that is not less than `v`

. For example, if `v`

is 41.2, then the ceiling is 42.

See also

`qFloor()`

Returns the cosine of an angle `v`

in radians.

See also

`qSin()`

`qTan()`

This function converts the `degrees`

in float to radians.

Example:

degrees = 180.0f radians = qDegreesToRadians(degrees)See also

`qRadiansToDegrees()`

This function converts the `degrees`

in double to radians.

Example:

degrees = 180.0 radians = qDegreesToRadians(degrees)See also

`qRadiansToDegrees()`

This function converts the `degrees`

in double to radians.

See also

`qRadiansToDegrees()`

Returns the exponential function of `e`

to the power of `v`

.

See also

`qLn()`

Returns the absolute value of `v`

.

Returns the floor of the value `v`

.

The floor is the largest integer that is not greater than `v`

. For example, if `v`

is 41.2, then the floor is 41.

See also

`qCeil()`

Returns the distance from origin in arbitrarily many dimensions

This is as for the two-argument and three-argument forms, supported by std::hypot(), but with as many numeric parameters as you care to pass to it. Uses `first`

and each of the `rest`

as co-ordinates, performing a calculation equivalent to squaring each, summing and returning the square root, save that underflow and overflow are avoided as far as possible.

See also

`qSqrt()`

This is an overloaded function.

Returns the distance of a point (x, y) from the origin (0, 0).

This is `qSqrt`

(x * x + y * y), optimized. In particular, underflow and overflow may be avoided.

Accepts any mix of numeric types, returning the same floating-point type as std::hypot(). If either parameter is infinite, so is the result; otherwise, if either is a NaN, so is the result.

See also

`qSqrt()`

`qAtan2()`

This is an overloaded function.

Returns the distance of a point (x, y, z) from the origin (0, 0, 0).

This is `qSqrt`

(x * x + y * y + z * z), optimized where supported. In particular, underflow and overflow may be avoided.

Accepts any mix of numeric types, returning the same floating-point type as std::hypot(). If any parameter is infinite, so is the result; otherwise, if any is NaN, so is the result.

See also

`qSqrt()`

Returns the natural logarithm of `v`

. Natural logarithm uses base e.

See also

`qExp()`

This function returns the nearest power of two greater than `value`

. For 0 it returns 1, and for values larger than or equal to 2^31 it returns 0.

This is an overloaded function.

This function returns the nearest power of two greater than `value`

. For negative values it returns 0.

This function returns the nearest power of two greater than `value`

. For 0 it returns 1, and for values larger than or equal to 2^63 it returns 0.

This is an overloaded function.

This function returns the nearest power of two greater than `value`

. For negative values it returns 0.

Returns the value of `x`

raised to the power of `y`

. That is, `x`

is the base and `y`

is the exponent.

See also

`qSqrt()`

This function converts the `radians`

in float to degrees.

Example:

radians = float(M_PI) degrees = qRadiansToDegrees(radians)See also

`qDegreesToRadians()`

This function converts the `radians`

in double to degrees.

Example:

radians = M_PI() degrees = qRadiansToDegrees(radians)See also

`qDegreesToRadians()`

This function converts the `radians`

in double to degrees.

See also

`qDegreesToRadians()`

Returns the sine of the angle `v`

in radians.

See also

`qCos()`

`qTan()`

Returns the square root of `v`

. This function returns a NaN if `v`

is a negative number.

See also

`qPow()`

`qHypot()`

Returns the tangent of an angle `v`

in radians.

See also

`qSin()`

`qCos()`

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.