# <QtMath> - Generic Math Functions

The <QtMath> header file provides various math functions. More...

## Functions

 qreal qAcos(qreal v) qreal qAsin(qreal v) qreal qAtan2(qreal y, qreal x) qreal qAtan(qreal v) int qCeil(qreal v) qreal qCos(qreal v) float qDegreesToRadians(float degrees) double qDegreesToRadians(double degrees) qreal qExp(qreal v) qreal qFabs(qreal v) int qFloor(qreal v) qreal qLn(qreal v) quint32 qNextPowerOfTwo(quint32 value) quint32 qNextPowerOfTwo(qint32 value) quint64 qNextPowerOfTwo(quint64 value) quint64 qNextPowerOfTwo(qint64 value) qreal qPow(qreal x, qreal y) float qRadiansToDegrees(float radians) double qRadiansToDegrees(double radians) qreal qSin(qreal v) qreal qSqrt(qreal v) qreal qTan(qreal v)

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

## Function Documentation

### qrealqAcos(qrealv)

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

See also qAtan(), qAsin(), and qCos().

### qrealqAsin(qrealv)

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

See also qSin(), qAtan(), and qAcos().

### qrealqAtan2(qrealy, qrealx)

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().

### qrealqAtan(qrealv)

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

See also qTan(), qAcos(), and qAsin().

### intqCeil(qrealv)

Return 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().

### qrealqCos(qrealv)

Returns the cosine of an angle v in radians.

See also qSin() and qTan().

### floatqDegreesToRadians(floatdegrees)

This function converts the degrees in float to radians.

Example:

```float degrees = 180.0f
float radians = qDegreesToRadians(degrees)```

This function was introduced in Qt 5.1.

See also qRadiansToDegrees().

### doubleqDegreesToRadians(doubledegrees)

This function converts the degrees in double to radians.

Example:

```double degrees = 180.0
double radians = qDegreesToRadians(degrees)```

This function was introduced in Qt 5.1.

See also qRadiansToDegrees().

### qrealqExp(qrealv)

Returns the exponential function of `e` to the power of v.

See also qLn().

### qrealqFabs(qrealv)

Returns the absolute value of v as a qreal.

### intqFloor(qrealv)

Return 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().

### qrealqLn(qrealv)

Returns the natural logarithm of v. Natural logarithm uses base e.

See also qExp().

### quint32qNextPowerOfTwo(quint32value)

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 function was introduced in Qt 5.4.

### quint32qNextPowerOfTwo(qint32value)

This is an overloaded function.

This function returns the nearest power of two greater than value. For negative values it returns 0.

This function was introduced in Qt 5.4.

### quint64qNextPowerOfTwo(quint64value)

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 function was introduced in Qt 5.4.

### quint64qNextPowerOfTwo(qint64value)

This is an overloaded function.

This function returns the nearest power of two greater than value. For negative values it returns 0.

This function was introduced in Qt 5.4.

### qrealqPow(qrealx, qrealy)

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().

### floatqRadiansToDegrees(floatradians)

This function converts the radians in float to degrees.

Example:

```float radians = float(M_PI)
float degrees = qRadiansToDegrees(radians)```

This function was introduced in Qt 5.1.

See also qDegreesToRadians().

### doubleqRadiansToDegrees(doubleradians)

This function converts the radians in double to degrees.

Example:

```double radians = M_PI
double degrees = qRadiansToDegrees(radians)```

This function was introduced in Qt 5.1.

See also qDegreesToRadians().

### qrealqSin(qrealv)

Returns the sine of the angle v in radians.

See also qCos() and qTan().

### qrealqSqrt(qrealv)

Returns the square root of v. This function returns a NaN if v is a negative number.

See also qPow().

### qrealqTan(qrealv)

Returns the tangent of an angle v in radians.

See also qSin() and qCos().

© 2019 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.