diff --git a/config.tests/unix/floatmath/floatmath.cpp b/config.tests/unix/floatmath/floatmath.cpp
deleted file mode 100644
index 4becf2a2662f77722f3b58d167459644cf00890d..0000000000000000000000000000000000000000
--- a/config.tests/unix/floatmath/floatmath.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the config.tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <math.h>
-
-int main(int argc, char **argv)
-{
-    float c = ceilf(1.3f);
-    float f = floorf(1.7f);
-    float s = sinf(3.8);
-    float t = cosf(7.3);
-    float u = sqrtf(8.4);
-    float l = logf(9.2);
-
-    if (c == 1.0f && f == 2.0f && s == 3.0f && t == 4.0f && u == 5.0f && l == 6.0f)
-        return 0;
-    else
-        return 1;
-}
-
diff --git a/config.tests/unix/floatmath/floatmath.pro b/config.tests/unix/floatmath/floatmath.pro
deleted file mode 100644
index 4c785638b2ec951274ea938c0d3872bb7ab67bc3..0000000000000000000000000000000000000000
--- a/config.tests/unix/floatmath/floatmath.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-SOURCES = floatmath.cpp
-CONFIG -= x11 qt
-
diff --git a/configure b/configure
index ecf223f074a8e7d40ba07fc4f167a04324e0b5aa..f74af093b9c2baeb096313e976368fef137a02d1 100755
--- a/configure
+++ b/configure
@@ -4261,13 +4261,6 @@ if [ "$CFG_CXX11" != "no" ]; then
     fi
 fi
 
-# detect availability of float math.h functions
-if compileTest unix/floatmath "floatmath"; then
-    CFG_USE_FLOATMATH=yes
-else
-    CFG_USE_FLOATMATH=no
-fi
-
 # detect sse2 support
 if [ "${CFG_SSE2}" = "auto" ]; then
     if compileTest common/sse2 "sse2"; then
@@ -6498,10 +6491,6 @@ fi
 # Add QPA to config.h
 QCONFIG_FLAGS="$QCONFIG_FLAGS"
 
-if [ "${CFG_USE_FLOATMATH}" = "yes" ]; then
-    QCONFIG_FLAGS="${QCONFIG_FLAGS} QT_USE_MATH_H_FLOATS"
-fi
-
 # Add turned on SQL drivers
 for DRIVER in $CFG_SQL_AVAILABLE; do
     eval "VAL=\$CFG_SQL_$DRIVER"
diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp
index e114fa0e7e142269d10a442c8677560a68d46349..d52a5f23203b807df3fb809833be7923355bcbb5 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.cpp
+++ b/examples/corelib/threads/mandelbrot/renderthread.cpp
@@ -41,8 +41,7 @@
 #include "renderthread.h"
 
 #include <QtWidgets>
-
-#include <math.h>
+#include <cmath>
 
 //! [0]
 RenderThread::RenderThread(QObject *parent)
@@ -207,9 +206,9 @@ uint RenderThread::rgbFromWaveLength(double wave)
     else if (wave <  420.0)
         s = 0.3 + 0.7 * (wave - 380.0) / (420.0 - 380.0);
 
-    r = pow(r * s, 0.8);
-    g = pow(g * s, 0.8);
-    b = pow(b * s, 0.8);
+    r = std::pow(r * s, 0.8);
+    g = std::pow(g * s, 0.8);
+    b = std::pow(b * s, 0.8);
     return qRgb(int(r * 255), int(g * 255), int(b * 255));
 }
 //! [10]
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.cpp b/examples/qtconcurrent/imagescaling/imagescaling.cpp
index 15b0e7ca5baad84c901aa4c593bc636a917cb4c9..169531119afa2ab90d7862afac287855d60f31eb 100644
--- a/examples/qtconcurrent/imagescaling/imagescaling.cpp
+++ b/examples/qtconcurrent/imagescaling/imagescaling.cpp
@@ -38,7 +38,7 @@
 **
 ****************************************************************************/
 #include "imagescaling.h"
-#include "math.h"
+#include <qmath.h>
 
 const int imageSize = 100;
 
@@ -110,7 +110,7 @@ void Images::open()
     qDeleteAll(labels);
     labels.clear();
 
-    int dim = sqrt(qreal(files.count())) + 1;
+    int dim = qSqrt(qreal(files.count())) + 1;
     for (int i = 0; i < dim; ++i) {
         for (int j = 0; j < dim; ++j) {
             QLabel *imageLabel = new QLabel;
diff --git a/examples/widgets/animation/animatedtiles/main.cpp b/examples/widgets/animation/animatedtiles/main.cpp
index f51f69f1ac62f21b7d2e44850120b0c738a58eba..5802d0f4cd2c1aca74fb04900785aad7e8b22837 100644
--- a/examples/widgets/animation/animatedtiles/main.cpp
+++ b/examples/widgets/animation/animatedtiles/main.cpp
@@ -39,6 +39,7 @@
 ****************************************************************************/
 
 #include <QtWidgets>
+#include <QtCore/qmath.h>
 #include <QtCore/qstate.h>
 
 class Pixmap : public QObject, public QGraphicsPixmapItem
@@ -181,13 +182,13 @@ int main(int argc, char **argv)
         Pixmap *item = items.at(i);
         // Ellipse
         ellipseState->assignProperty(item, "pos",
-                                         QPointF(cos((i / 63.0) * 6.28) * 250,
-                                                 sin((i / 63.0) * 6.28) * 250));
+                                         QPointF(qCos((i / 63.0) * 6.28) * 250,
+                                                 qSin((i / 63.0) * 6.28) * 250));
 
         // Figure 8
         figure8State->assignProperty(item, "pos",
-                                         QPointF(sin((i / 63.0) * 6.28) * 250,
-                                                 sin(((i * 2)/63.0) * 6.28) * 250));
+                                         QPointF(qSin((i / 63.0) * 6.28) * 250,
+                                                 qSin(((i * 2)/63.0) * 6.28) * 250));
 
         // Random
         randomState->assignProperty(item, "pos",
diff --git a/examples/widgets/effects/blurpicker/blurpicker.cpp b/examples/widgets/effects/blurpicker/blurpicker.cpp
index f354a15c53f6ab2da4cba5959113b44e9347bae9..b5ac7950bd0ed5eab671acd096ec9a018a3737ee 100644
--- a/examples/widgets/effects/blurpicker/blurpicker.cpp
+++ b/examples/widgets/effects/blurpicker/blurpicker.cpp
@@ -41,6 +41,7 @@
 #include "blurpicker.h"
 
 #include <QtWidgets>
+#include <QtCore/qmath.h>
 
 #include "blureffect.h"
 
@@ -76,8 +77,8 @@ void BlurPicker::setIndex(qreal index)
     for (int i = 0; i < m_icons.count(); ++i) {
         QGraphicsItem *icon = m_icons[i];
         qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count();
-        qreal xs = 170 * sin(a);
-        qreal ys = 100 * cos(a);
+        qreal xs = 170 * qSin(a);
+        qreal ys = 100 * qCos(a);
         QPointF pos(xs, ys);
         pos = QTransform().rotate(-20).map(pos);
         pos -= QPointF(40, 40);
diff --git a/examples/widgets/effects/lighting/lighting.cpp b/examples/widgets/effects/lighting/lighting.cpp
index 1bf18160b461263ad94b60a0b196a88cc270cd37..67bcb8147b36280936fee7a4734dac6b0eea1f67 100644
--- a/examples/widgets/effects/lighting/lighting.cpp
+++ b/examples/widgets/effects/lighting/lighting.cpp
@@ -41,6 +41,7 @@
 #include "lighting.h"
 
 #include <QtWidgets>
+#include <QtCore/qmath.h>
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -110,8 +111,8 @@ void Lighting::setupScene()
 void Lighting::animate()
 {
     angle += (M_PI / 30);
-    qreal xs = 200 * sin(angle) - 40 + 25;
-    qreal ys = 200 * cos(angle) - 40 + 25;
+    qreal xs = 200 * qSin(angle) - 40 + 25;
+    qreal ys = 200 * qCos(angle) - 40 + 25;
     m_lightSource->setPos(xs, ys);
 
     for (int i = 0; i < m_items.size(); ++i) {
@@ -125,7 +126,7 @@ void Lighting::animate()
 
         qreal dx = delta.x();
         qreal dy = delta.y();
-        qreal dd = sqrt(dx * dx + dy * dy);
+        qreal dd = qSqrt(dx * dx + dy * dy);
         QColor color = effect->color();
         color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7));
         effect->setColor(color);
diff --git a/examples/widgets/graphicsview/boxes/qtbox.cpp b/examples/widgets/graphicsview/boxes/qtbox.cpp
index e368ddb30797759d7c831e54cdd404bcf1ee31e4..5e142832e07f8a0309cd8e0dea7c2e47ebfc23fa 100644
--- a/examples/widgets/graphicsview/boxes/qtbox.cpp
+++ b/examples/widgets/graphicsview/boxes/qtbox.cpp
@@ -242,7 +242,7 @@ void ItemBase::keyPressEvent(QKeyEvent *event)
 void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event)
 {
     prepareGeometryChange();
-    m_size = int(m_size * exp(-event->delta() / 600.0));
+    m_size = int(m_size * qExp(-event->delta() / 600.0));
     if (m_size > MAX_ITEM_SIZE)
         m_size = MAX_ITEM_SIZE;
     else if (m_size < MIN_ITEM_SIZE)
@@ -404,10 +404,10 @@ void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
 {
     int dt = m_startTime.msecsTo(QTime::currentTime());
 
-    qreal r0 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 3800) % 4000)));
-    qreal r1 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 0) % 4000)));
-    qreal r2 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 1800) % 4000)));
-    qreal r3 = 0.5 * m_size * (1.0 - exp(-0.001 * ((dt + 2000) % 4000)));
+    qreal r0 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 3800) % 4000)));
+    qreal r1 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 0) % 4000)));
+    qreal r2 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 1800) % 4000)));
+    qreal r3 = 0.5 * m_size * (1.0 - qExp(-0.001 * ((dt + 2000) % 4000)));
 
     if (r0 > r1)
         r0 = 0.0;
diff --git a/examples/widgets/graphicsview/boxes/scene.cpp b/examples/widgets/graphicsview/boxes/scene.cpp
index 2ca061a43a8d253d430a490ac985fede471d29d0..48bdcb9d9310291345acea1f8eb701c446d0dc67 100644
--- a/examples/widgets/graphicsview/boxes/scene.cpp
+++ b/examples/widgets/graphicsview/boxes/scene.cpp
@@ -35,6 +35,7 @@
 #include "scene.h"
 #include <QtGui/qmatrix4x4.h>
 #include <QtGui/qvector3d.h>
+#include <cmath>
 
 #include "3rdparty/fbm.h"
 
@@ -856,7 +857,7 @@ void Scene::renderCubemaps()
 
         float angle = 2.0f * PI * i / m_cubemaps.size();
 
-        center = m_trackBalls[1].rotation().rotatedVector(QVector3D(cos(angle), sin(angle), 0.0f));
+        center = m_trackBalls[1].rotation().rotatedVector(QVector3D(std::cos(angle), std::sin(angle), 0.0f));
 
         for (int face = 0; face < 6; ++face) {
             m_cubemaps[i]->begin(face);
@@ -910,7 +911,7 @@ void Scene::drawBackground(QPainter *painter, const QRectF &)
 
     QMatrix4x4 view;
     view.rotate(m_trackBalls[2].rotation());
-    view(2, 3) -= 2.0f * exp(m_distExp / 1200.0f);
+    view(2, 3) -= 2.0f * std::exp(m_distExp / 1200.0f);
     renderBoxes(view);
 
     defaultStates();
diff --git a/examples/widgets/graphicsview/boxes/trackball.cpp b/examples/widgets/graphicsview/boxes/trackball.cpp
index 2267636fa43e3559a40a38f4d78df3791b146da1..b1159b49898b5576ab8e593865e5ee7c6157a9c4 100644
--- a/examples/widgets/graphicsview/boxes/trackball.cpp
+++ b/examples/widgets/graphicsview/boxes/trackball.cpp
@@ -33,6 +33,7 @@
 
 #include "trackball.h"
 #include "scene.h"
+#include <cmath>
 
 //============================================================================//
 //                                  TrackBall                                 //
@@ -94,19 +95,19 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation)
             QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f);
             float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D);
             if (sqrZ > 0)
-                lastPos3D.setZ(sqrt(sqrZ));
+                lastPos3D.setZ(std::sqrt(sqrZ));
             else
                 lastPos3D.normalize();
 
             QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f);
             sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D);
             if (sqrZ > 0)
-                currentPos3D.setZ(sqrt(sqrZ));
+                currentPos3D.setZ(std::sqrt(sqrZ));
             else
                 currentPos3D.normalize();
 
             m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D);
-            float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis)));
+            float angle = 180 / PI * std::asin(std::sqrt(QVector3D::dotProduct(m_axis, m_axis)));
 
             m_angularVelocity = angle / msecs;
             m_axis.normalize();
diff --git a/examples/widgets/itemviews/chart/pieview.cpp b/examples/widgets/itemviews/chart/pieview.cpp
index 6e55afa5f0022566218b5ec71d884fd2a6cc5c9e..9793e7d89b3faaf5f3adfd0f5bf2290ea7d50e31 100644
--- a/examples/widgets/itemviews/chart/pieview.cpp
+++ b/examples/widgets/itemviews/chart/pieview.cpp
@@ -38,8 +38,8 @@
 **
 ****************************************************************************/
 
-#include <math.h>
 #include <QtWidgets>
+#include <cmath>
 
 #ifndef M_PI
 #define M_PI 3.1415927
@@ -109,13 +109,13 @@ QModelIndex PieView::indexAt(const QPoint &point) const
         double cy = totalSize / 2 - wy; // positive cy for items above the center
 
         // Determine the distance from the center point of the pie chart.
-        double d = pow(pow(cx, 2) + pow(cy, 2), 0.5);
+        double d = std::sqrt(std::pow(cx, 2) + std::pow(cy, 2));
 
         if (d == 0 || d > pieSize / 2)
             return QModelIndex();
 
         // Determine the angle of the point.
-        double angle = (180 / M_PI) * acos(cx / d);
+        double angle = (180 / M_PI) * std::acos(cx / d);
         if (cy < 0)
             angle = 360 - angle;
 
diff --git a/examples/widgets/itemviews/stardelegate/starrating.cpp b/examples/widgets/itemviews/stardelegate/starrating.cpp
index af67ae11da7d0af57ca4c1843d8ed57ca3e642e5..568666f93ab55d92090280fc3413abfe08540aca 100644
--- a/examples/widgets/itemviews/stardelegate/starrating.cpp
+++ b/examples/widgets/itemviews/stardelegate/starrating.cpp
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 #include <QtWidgets>
-#include <math.h>
+#include <cmath>
 
 #include "starrating.h"
 
@@ -53,8 +53,8 @@ StarRating::StarRating(int starCount, int maxStarCount)
 
     starPolygon << QPointF(1.0, 0.5);
     for (int i = 1; i < 5; ++i)
-        starPolygon << QPointF(0.5 + 0.5 * cos(0.8 * i * 3.14),
-                               0.5 + 0.5 * sin(0.8 * i * 3.14));
+        starPolygon << QPointF(0.5 + 0.5 * std::cos(0.8 * i * 3.14),
+                               0.5 + 0.5 * std::sin(0.8 * i * 3.14));
 
     diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4)
                    << QPointF(0.6, 0.5) << QPointF(0.5, 0.6)
diff --git a/examples/widgets/itemviews/storageview/storagemodel.cpp b/examples/widgets/itemviews/storageview/storagemodel.cpp
index d70f53ce89d9901b1125dbc78d8ccbb3e28b8cb8..9f8d229c77bf6ff6b22257f6ee7f29c70fc83c1b 100644
--- a/examples/widgets/itemviews/storageview/storagemodel.cpp
+++ b/examples/widgets/itemviews/storageview/storagemodel.cpp
@@ -43,6 +43,7 @@
 
 #include <QDir>
 #include <qmath.h>
+#include <cmath>
 
 static QString sizeToString(qint64 size)
 {
@@ -51,11 +52,11 @@ static QString sizeToString(qint64 size)
     if (size <= 0)
         return StorageModel::tr("0 b");
 
-    double power = log((double)size)/log(1024.0);
+    double power = std::log((double)size)/std::log(1024.0);
     int intPower = (int)power;
     intPower = intPower >= 8 ? 8 - 1 : intPower;
 
-    double normSize = size / pow(1024.0, intPower);
+    double normSize = size / std::pow(1024.0, intPower);
     //: this should expand to "1.23 GB"
     return StorageModel::tr("%1 %2").arg(normSize, 0, 'f', intPower > 0 ? 2 : 0).arg(strings[intPower]);
 }
diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp
index 5b1acf9c01f2a3d2cf55e2e9984a9bc32c0d8db0..d3311075f5b1d2e7debe819afbe9443755992292 100644
--- a/examples/widgets/painting/painterpaths/window.cpp
+++ b/examples/widgets/painting/painterpaths/window.cpp
@@ -43,7 +43,7 @@
 
 #include <QtWidgets>
 
-#include <math.h>
+#include <cmath>
 
 //! [0]
 const float Pi = 3.14159f;
@@ -123,8 +123,8 @@ Window::Window()
     QPainterPath starPath;
     starPath.moveTo(90, 50);
     for (int i = 1; i < 5; ++i) {
-        starPath.lineTo(50 + 40 * cos(0.8 * i * Pi),
-                        50 + 40 * sin(0.8 * i * Pi));
+        starPath.lineTo(50 + 40 * std::cos(0.8 * i * Pi),
+                        50 + 40 * std::sin(0.8 * i * Pi));
     }
     starPath.closeSubpath();
 //! [9]
diff --git a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
index b3e45b585bb1956647326ae2b0c6dcc7d0dbfbae..a5ca14a39c469559f5dc350e0281e7d4b583854c 100644
--- a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
+++ b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
@@ -40,7 +40,7 @@
 
 #include <QtWidgets>
 
-#include <math.h>
+#include <cmath>
 #include <stdlib.h>
 
 #include "basictoolsplugin.h"
@@ -139,8 +139,8 @@ QPainterPath BasicToolsPlugin::generateShape(const QString &shape,
     } else if (shape == tr("Star")) {
         path.moveTo(90, 50);
         for (int i = 1; i < 5; ++i) {
-            path.lineTo(50 + 40 * cos(0.8 * i * Pi),
-                        50 + 40 * sin(0.8 * i * Pi));
+            path.lineTo(50 + 40 * std::cos(0.8 * i * Pi),
+                        50 + 40 * std::sin(0.8 * i * Pi));
         }
         path.closeSubpath();
     } else if (shape == tr("Text...")) {
diff --git a/examples/widgets/widgets/calculator/calculator.cpp b/examples/widgets/widgets/calculator/calculator.cpp
index 620c61a804e218cdede54eb9f120b5d95135323f..e76011ee0d97188c49ba39fa43f2df1d826deb3c 100644
--- a/examples/widgets/widgets/calculator/calculator.cpp
+++ b/examples/widgets/widgets/calculator/calculator.cpp
@@ -40,7 +40,7 @@
 
 #include <QtWidgets>
 
-#include <math.h>
+#include <cmath>
 
 #include "button.h"
 #include "calculator.h"
@@ -164,9 +164,9 @@ void Calculator::unaryOperatorClicked()
             abortOperation();
             return;
         }
-        result = sqrt(operand);
+        result = std::sqrt(operand);
     } else if (clickedOperator == tr("x\302\262")) {
-        result = pow(operand, 2.0);
+        result = std::pow(operand, 2.0);
     } else if (clickedOperator == tr("1/x")) {
         if (operand == 0.0) {
             abortOperation();
diff --git a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
index e37212b475ef19e75e51260c5573c3fc1c380bcd..c311db957c8b4ce7cb9928d0b08047e3f54860fa 100644
--- a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp
@@ -257,7 +257,7 @@ while (i.hasNext()) {
 QMutableListIterator<double> i(list);
 while (i.hasNext()) {
     double val = i.next();
-    i.setValue(sqrt(val));
+    i.setValue(std::sqrt(val));
 }
 //! [23]
 
@@ -266,7 +266,7 @@ while (i.hasNext()) {
 QMutableLinkedListIterator<double> i(list);
 while (i.hasNext()) {
     double val = i.next();
-    i.setValue(sqrt(val));
+    i.setValue(std::sqrt(val));
 }
 //! [24]
 
@@ -275,7 +275,7 @@ while (i.hasNext()) {
 QMutableVectorIterator<double> i(list);
 while (i.hasNext()) {
     double val = i.next();
-    i.setValue(sqrt(val));
+    i.setValue(std::sqrt(val));
 }
 //! [25]
 
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp
index 17a252cc1bbb919cc282cd196a4b2502140b93a0..b545c2dad87199533ebb2d7f44918bd83454f4ee 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp
@@ -105,7 +105,7 @@ MyWidget::mouseMoveEvent(QMouseEvent *event)
 
 
 //! [8]
-double trueLength = sqrt(pow(x(), 2) + pow(y(), 2));
+double trueLength = std::sqrt(std::pow(x(), 2) + std::pow(y(), 2));
 //! [8]
 
 
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index 2395e9ee1c15f3d4f6bfe487a23083f960b2598e..5cc3ec586ed063ca020d8db29f365f32825a578f 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -38,13 +38,11 @@
 #pragma qt_class(QtMath)
 #endif
 
-#include <math.h>
-
 #include <QtCore/qglobal.h>
-#include <QtCore/qcompilerdetection.h>
 
-QT_BEGIN_NAMESPACE
+#include <cmath>
 
+QT_BEGIN_NAMESPACE
 
 #define QT_SINE_TABLE_SIZE 256
 
@@ -52,139 +50,86 @@ extern Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE];
 
 inline int qCeil(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return int(ceilf(float(v)));
-    else
-#endif
-        return int(ceil(v));
+    using std::ceil;
+    return int(ceil(v));
 }
 
 inline int qFloor(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return int(floorf(float(v)));
-    else
-#endif
-        return int(floor(v));
+    using std::floor;
+    return int(floor(v));
 }
 
 inline qreal qFabs(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if(sizeof(qreal) == sizeof(float))
-        return fabsf(float(v));
-    else
-#endif
-        return fabs(v);
+    using std::fabs;
+    return fabs(v);
 }
 
 inline qreal qSin(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return sinf(float(v));
-    else
-#endif
-        return sin(v);
+    using std::sin;
+    return sin(v);
 }
 
 inline qreal qCos(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return cosf(float(v));
-    else
-#endif
-        return cos(v);
+    using std::cos;
+    return cos(v);
 }
 
 inline qreal qTan(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return tanf(float(v));
-    else
-#endif
-        return tan(v);
+    using std::tan;
+    return tan(v);
 }
 
 inline qreal qAcos(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return acosf(float(v));
-    else
-#endif
-       return acos(v);
+    using std::acos;
+    return acos(v);
 }
 
 inline qreal qAsin(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return asinf(float(v));
-    else
-#endif
-        return asin(v);
+    using std::asin;
+    return asin(v);
 }
 
 inline qreal qAtan(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return atanf(float(v));
-    else
-#endif
-        return atan(v);
+    using std::atan;
+    return atan(v);
 }
 
 inline qreal qAtan2(qreal y, qreal x)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return atan2f(float(y), float(x));
-    else
-#endif
-        return atan2(y, x);
+    using std::atan2;
+    return atan2(y, x);
 }
 
 inline qreal qSqrt(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return sqrtf(float(v));
-    else
-#endif
-        return sqrt(v);
+    using std::sqrt;
+    return sqrt(v);
 }
 
 inline qreal qLn(qreal v)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return logf(float(v));
-    else
-#endif
-        return log(v);
+    using std::log;
+    return log(v);
 }
 
 inline qreal qExp(qreal v)
 {
-    // only one signature
-    // exists, exp(double)
+    using std::exp;
     return exp(v);
 }
 
 inline qreal qPow(qreal x, qreal y)
 {
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return powf(float(x), float(y));
-    else
-#endif
-        return pow(x, y);
+    using std::pow;
+    return pow(x, y);
 }
 
 #ifndef M_E
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index c1d74b3b43ba3e8244f95354be756c5cbc84ff27..1bd9c5ebb92b86e85df7598e9d0aabfadbd7f20e 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -657,7 +657,7 @@ struct BezierEase : public QEasingCurveFunction
 
     qreal static inline _acos(qreal x)
     {
-        return sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f)));
+        return std::sqrt(1-x)*(1.5707963267948966192313216916398f + x*(-0.213300989f + x*(0.077980478f + x*-0.02164095f)));
     }
 
     qreal static inline _cos(qreal x) //super fast _cos
@@ -704,8 +704,8 @@ struct BezierEase : public QEasingCurveFunction
         //We use approximations instead
 
         const qreal x_squared = x * x;
-        const qreal x_plus_one_sqrt = sqrt(1.0 + x);
-        const qreal one_minus_x_sqrt = sqrt(1.0 - x);
+        const qreal x_plus_one_sqrt = qSqrt(1.0 + x);
+        const qreal one_minus_x_sqrt = qSqrt(1.0 - x);
 
         //cos(acos(x) / 3)
         //s1 = _cos(_acos(x) / 3);
@@ -743,7 +743,7 @@ struct BezierEase : public QEasingCurveFunction
         const qreal D = 0.25 * q_squared + p_cubic / 27.0;
 
         if (D >= 0) {
-            const qreal D_sqrt = sqrt(D);
+            const qreal D_sqrt = qSqrt(D);
             qreal u = _cbrt( -q * 0.5 + D_sqrt);
             qreal v = _cbrt( -q * 0.5 - D_sqrt);
             qreal z1 = u + v;
@@ -758,13 +758,13 @@ struct BezierEase : public QEasingCurveFunction
         }
 
         //casus irreducibilis
-        const qreal p_minus_sqrt = sqrt(-p);
+        const qreal p_minus_sqrt = qSqrt(-p);
 
         //const qreal f = sqrt(4.0 / 3.0 * -p);
-        const qreal f = sqrt(4.0 / 3.0) * p_minus_sqrt;
+        const qreal f = qSqrt(4.0 / 3.0) * p_minus_sqrt;
 
         //const qreal sqrtP = sqrt(27.0 / -p_cubic);
-        const qreal sqrtP = -3.0*sqrt(3.0) / (p_minus_sqrt * p);
+        const qreal sqrtP = -3.0*qSqrt(3.0) / (p_minus_sqrt * p);
 
 
         const qreal g = -q * 0.5 * sqrtP;
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index 42aae6c20cda1f93fd7e9e89e44f641ece04e54b..c196f7cff8b1013e0157769c6096d49ca5b22063 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -1125,8 +1125,8 @@ void QMatrix4x4::rotate(float angle, float x, float y, float z)
         c = -1.0f;
     } else {
         float a = angle * M_PI / 180.0f;
-        c = cosf(a);
-        s = sinf(a);
+        c = std::cos(a);
+        s = std::sin(a);
     }
     if (x == 0.0f) {
         if (y == 0.0f) {
@@ -1186,7 +1186,7 @@ void QMatrix4x4::rotate(float angle, float x, float y, float z)
                  double(y) * double(y) +
                  double(z) * double(z);
     if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) {
-        len = sqrt(len);
+        len = std::sqrt(len);
         x = float(double(x) / len);
         y = float(double(y) / len);
         z = float(double(z) / len);
@@ -1234,8 +1234,8 @@ void QMatrix4x4::projectedRotate(float angle, float x, float y, float z)
         c = -1.0f;
     } else {
         float a = angle * M_PI / 180.0f;
-        c = cosf(a);
-        s = sinf(a);
+        c = std::cos(a);
+        s = std::sin(a);
     }
     if (x == 0.0f) {
         if (y == 0.0f) {
@@ -1282,7 +1282,7 @@ void QMatrix4x4::projectedRotate(float angle, float x, float y, float z)
                  double(y) * double(y) +
                  double(z) * double(z);
     if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) {
-        len = sqrt(len);
+        len = std::sqrt(len);
         x = float(double(x) / len);
         y = float(double(y) / len);
         z = float(double(z) / len);
@@ -1487,10 +1487,10 @@ void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearP
     // Construct the projection.
     QMatrix4x4 m(1);
     float radians = (verticalAngle / 2.0f) * M_PI / 180.0f;
-    float sine = sinf(radians);
+    float sine = std::sin(radians);
     if (sine == 0.0f)
         return;
-    float cotan = cosf(radians) / sine;
+    float cotan = std::cos(radians) / sine;
     float clip = farPlane - nearPlane;
     m.m[0][0] = cotan / aspectRatio;
     m.m[1][0] = 0.0f;
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 0653ace5a4580971e42854e94be1028e524dc984..f2e79cb83442efa7e3fb8c6308af4ce85dbd8d22 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -219,7 +219,7 @@ QT_BEGIN_NAMESPACE
 */
 float QQuaternion::length() const
 {
-    return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
+    return std::sqrt(xp * xp + yp * yp + zp * zp + wp * wp);
 }
 
 /*!
@@ -252,7 +252,7 @@ QQuaternion QQuaternion::normalized() const
     if (qFuzzyIsNull(len - 1.0f))
         return *this;
     else if (!qFuzzyIsNull(len))
-        return *this / qSqrt(len);
+        return *this / std::sqrt(len);
     else
         return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
 }
@@ -273,7 +273,7 @@ void QQuaternion::normalize()
     if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
         return;
 
-    len = qSqrt(len);
+    len = std::sqrt(len);
 
     xp /= len;
     yp /= len;
@@ -386,8 +386,8 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, float angle)
     // We normalize the result just in case the values are close
     // to zero, as suggested in the above FAQ.
     float a = (angle / 2.0f) * M_PI / 180.0f;
-    float s = sinf(a);
-    float c = cosf(a);
+    float s = std::sin(a);
+    float c = std::cos(a);
     QVector3D ax = axis.normalized();
     return QQuaternion(c, ax.x() * s, ax.y() * s, ax.z() * s).normalized();
 }
@@ -415,12 +415,12 @@ void QQuaternion::toAxisAndAngle(float *x, float *y, float *z, float *angle) con
         *y = yp;
         *z = zp;
         if (!qFuzzyIsNull(length - 1.0f)) {
-            length = sqrtf(length);
+            length = std::sqrt(length);
             *x /= length;
             *y /= length;
             *z /= length;
         }
-        *angle = 2.0f * acosf(wp);
+        *angle = 2.0f * std::acos(wp);
     } else {
         // angle is 0 (mod 2*pi), so any axis will fit
         *x = *y = *z = *angle = 0.0f;
@@ -438,15 +438,15 @@ void QQuaternion::toAxisAndAngle(float *x, float *y, float *z, float *angle) con
 QQuaternion QQuaternion::fromAxisAndAngle
         (float x, float y, float z, float angle)
 {
-    float length = qSqrt(x * x + y * y + z * z);
+    float length = std::sqrt(x * x + y * y + z * z);
     if (!qFuzzyIsNull(length - 1.0f) && !qFuzzyIsNull(length)) {
         x /= length;
         y /= length;
         z /= length;
     }
     float a = (angle / 2.0f) * M_PI / 180.0f;
-    float s = sinf(a);
-    float c = cosf(a);
+    float s = std::sin(a);
+    float c = std::cos(a);
     return QQuaternion(c, x * s, y * s, z * s).normalized();
 }
 
@@ -515,20 +515,20 @@ void QQuaternion::toEulerAngles(float *pitch, float *yaw, float *roll) const
         zw /= lengthSquared;
     }
 
-    *pitch = asinf(-2.0f * (yz - xw));
+    *pitch = std::asin(-2.0f * (yz - xw));
     if (*pitch < M_PI_2) {
         if (*pitch > -M_PI_2) {
-            *yaw = atan2f(2.0f * (xz + yw), 1.0f - 2.0f * (xx + yy));
-            *roll = atan2f(2.0f * (xy + zw), 1.0f - 2.0f * (xx + zz));
+            *yaw = std::atan2(2.0f * (xz + yw), 1.0f - 2.0f * (xx + yy));
+            *roll = std::atan2(2.0f * (xy + zw), 1.0f - 2.0f * (xx + zz));
         } else {
             // not a unique solution
             *roll = 0.0f;
-            *yaw = -atan2f(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz));
+            *yaw = -std::atan2(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz));
         }
     } else {
         // not a unique solution
         *roll = 0.0f;
-        *yaw = atan2f(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz));
+        *yaw = std::atan2(-2.0f * (xy - zw), 1.0f - 2.0f * (yy + zz));
     }
 
     *pitch = qRadiansToDegrees(*pitch);
@@ -558,12 +558,12 @@ QQuaternion QQuaternion::fromEulerAngles(float pitch, float yaw, float roll)
     yaw *= 0.5f;
     roll *= 0.5f;
 
-    const float c1 = cosf(yaw);
-    const float s1 = sinf(yaw);
-    const float c2 = cosf(roll);
-    const float s2 = sinf(roll);
-    const float c3 = cosf(pitch);
-    const float s3 = sinf(pitch);
+    const float c1 = std::cos(yaw);
+    const float s1 = std::sin(yaw);
+    const float c2 = std::cos(roll);
+    const float s2 = std::sin(roll);
+    const float c3 = std::cos(pitch);
+    const float s3 = std::sin(pitch);
     const float c1c2 = c1 * c2;
     const float s1s2 = s1 * s2;
 
@@ -635,7 +635,7 @@ QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3)
 
     const float trace = rot3x3(0, 0) + rot3x3(1, 1) + rot3x3(2, 2);
     if (trace > 0.00000001f) {
-        const float s = 2.0f * sqrtf(trace + 1.0f);
+        const float s = 2.0f * std::sqrt(trace + 1.0f);
         scalar = 0.25f * s;
         axis[0] = (rot3x3(2, 1) - rot3x3(1, 2)) / s;
         axis[1] = (rot3x3(0, 2) - rot3x3(2, 0)) / s;
@@ -650,7 +650,7 @@ QQuaternion QQuaternion::fromRotationMatrix(const QMatrix3x3 &rot3x3)
         int j = s_next[i];
         int k = s_next[j];
 
-        const float s = 2.0f * sqrtf(rot3x3(i, i) - rot3x3(j, j) - rot3x3(k, k) + 1.0f);
+        const float s = 2.0f * std::sqrt(rot3x3(i, i) - rot3x3(j, j) - rot3x3(k, k) + 1.0f);
         axis[i] = 0.25f * s;
         scalar = (rot3x3(k, j) - rot3x3(j, k)) / s;
         axis[j] = (rot3x3(j, i) + rot3x3(i, j)) / s;
@@ -792,11 +792,11 @@ QQuaternion QQuaternion::slerp
     float factor1 = 1.0f - t;
     float factor2 = t;
     if ((1.0f - dot) > 0.0000001) {
-        float angle = acosf(dot);
-        float sinOfAngle = sinf(angle);
+        float angle = std::acos(dot);
+        float sinOfAngle = std::sin(angle);
         if (sinOfAngle > 0.0000001) {
-            factor1 = sinf((1.0f - t) * angle) / sinOfAngle;
-            factor2 = sinf(t * angle) / sinOfAngle;
+            factor1 = std::sin((1.0f - t) * angle) / sinOfAngle;
+            factor2 = std::sin(t * angle) / sinOfAngle;
         }
     }
 
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index bad46c6e0bf084ae863f75649a339358981a1cda..fe4c9f8cc20083ba3a7ca3cc2589ae731a674ff1 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -189,7 +189,7 @@ float QVector2D::length() const
     // Need some extra precision if the length is very small.
     double len = double(xp) * double(xp) +
                  double(yp) * double(yp);
-    return float(sqrt(len));
+    return float(std::sqrt(len));
 }
 
 /*!
@@ -220,7 +220,7 @@ QVector2D QVector2D::normalized() const
     if (qFuzzyIsNull(len - 1.0f)) {
         return *this;
     } else if (!qFuzzyIsNull(len)) {
-        double sqrtLen = sqrt(len);
+        double sqrtLen = std::sqrt(len);
         return QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen));
     } else {
         return QVector2D();
@@ -241,7 +241,7 @@ void QVector2D::normalize()
     if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
         return;
 
-    len = sqrt(len);
+    len = std::sqrt(len);
 
     xp = float(double(xp) / len);
     yp = float(double(yp) / len);
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index fa09a43480452d12ceaa47db3b2bd20ea1988740..a93d994a7044cf580076ab2720a739205aacd583 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -235,7 +235,7 @@ QVector3D QVector3D::normalized() const
     if (qFuzzyIsNull(len - 1.0f)) {
         return *this;
     } else if (!qFuzzyIsNull(len)) {
-        double sqrtLen = sqrt(len);
+        double sqrtLen = std::sqrt(len);
         return QVector3D(float(double(xp) / sqrtLen),
                          float(double(yp) / sqrtLen),
                          float(double(zp) / sqrtLen));
@@ -259,7 +259,7 @@ void QVector3D::normalize()
     if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
         return;
 
-    len = sqrt(len);
+    len = std::sqrt(len);
 
     xp = float(double(xp) / len);
     yp = float(double(yp) / len);
@@ -679,7 +679,7 @@ float QVector3D::length() const
     double len = double(xp) * double(xp) +
                  double(yp) * double(yp) +
                  double(zp) * double(zp);
-    return float(sqrt(len));
+    return float(std::sqrt(len));
 }
 
 /*!
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 1eed1c1301433c623149db3bf980a401f185b80b..6afe9b8cad52c95718c4b7b10082862545035114 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -256,7 +256,7 @@ float QVector4D::length() const
                  double(yp) * double(yp) +
                  double(zp) * double(zp) +
                  double(wp) * double(wp);
-    return float(sqrt(len));
+    return float(std::sqrt(len));
 }
 
 /*!
@@ -289,7 +289,7 @@ QVector4D QVector4D::normalized() const
     if (qFuzzyIsNull(len - 1.0f)) {
         return *this;
     } else if (!qFuzzyIsNull(len)) {
-        double sqrtLen = sqrt(len);
+        double sqrtLen = std::sqrt(len);
         return QVector4D(float(double(xp) / sqrtLen),
                          float(double(yp) / sqrtLen),
                          float(double(zp) / sqrtLen),
@@ -315,7 +315,7 @@ void QVector4D::normalize()
     if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
         return;
 
-    len = sqrt(len);
+    len = std::sqrt(len);
 
     xp = float(double(xp) / len);
     yp = float(double(yp) / len);
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index c23e0c28ea92821156ff405fd4cdafaa928dcdb1..576558022e83839ace27e068ca4e898c7f56cf6d 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -462,8 +462,8 @@ void QOpenGL2PaintEngineExPrivate::updateMatrix()
     // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.
     if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
         // 0.50 needs to rounded down to 0.0 for consistency with raster engine:
-        dx = ceilf(dx - 0.5f);
-        dy = ceilf(dy - 0.5f);
+        dx = std::ceil(dx - 0.5f);
+        dy = std::ceil(dy - 0.5f);
     }
     pmvMatrix[0][0] = (wfactor * transform.m11())  - transform.m13();
     pmvMatrix[1][0] = (wfactor * transform.m21())  - transform.m23();
diff --git a/src/gui/opengl/qtriangulatingstroker_p.h b/src/gui/opengl/qtriangulatingstroker_p.h
index 2561810d7aacc999f7ebcd18e65d5dbbbcf7d81c..dd46cbe1e5cf6ea7ef0cc149f99a78ae25a555cd 100644
--- a/src/gui/opengl/qtriangulatingstroker_p.h
+++ b/src/gui/opengl/qtriangulatingstroker_p.h
@@ -134,11 +134,11 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl
     float pw;
 
     if (dx == 0)
-        pw = m_width / qAbs(dy);
+        pw = m_width / std::abs(dy);
     else if (dy == 0)
-        pw = m_width / qAbs(dx);
+        pw = m_width / std::abs(dx);
     else
-        pw = m_width / sqrt(dx*dx + dy*dy);
+        pw = m_width / std::sqrt(dx*dx + dy*dy);
 
     *nx = -dy * pw;
     *ny = dx * pw;
diff --git a/src/gui/opengl/qtriangulator.cpp b/src/gui/opengl/qtriangulator.cpp
index b0d754b87e9549a2b7e45b4c4f712440f44c6f86..6574fe997594461a4b9127488f5df7c9d7d62ee4 100644
--- a/src/gui/opengl/qtriangulator.cpp
+++ b/src/gui/opengl/qtriangulator.cpp
@@ -49,8 +49,6 @@
 #include <private/qopenglextensions_p.h>
 #include <private/qrbtree_p.h>
 
-#include <math.h>
-
 QT_BEGIN_NAMESPACE
 
 //#define Q_TRIANGULATOR_DEBUG
@@ -1700,8 +1698,8 @@ void QTriangulator<T>::ComplexToSimple::DebugDialog::paintEvent(QPaintEvent *)
         QPodPoint q = vertices.at(splits.at(i).vertex);
         QPodPoint u = vertices.at(edges.at(splits.at(i).edge).from) - q;
         QPodPoint v = vertices.at(edges.at(splits.at(i).edge).to) - q;
-        qreal uLen = sqrt(qreal(qDot(u, u)));
-        qreal vLen = sqrt(qreal(qDot(v, v)));
+        qreal uLen = qSqrt(qDot(u, u));
+        qreal vLen = qSqrt(qDot(v, v));
         if (uLen) {
             u.x *= 2 * halfPointSize / uLen;
             u.y *= 2 * halfPointSize / uLen;
@@ -1719,7 +1717,7 @@ void QTriangulator<T>::ComplexToSimple::DebugDialog::paintEvent(QPaintEvent *)
 template <typename T>
 void QTriangulator<T>::ComplexToSimple::DebugDialog::wheelEvent(QWheelEvent *event)
 {
-    qreal scale = exp(-0.001 * event->delta());
+    qreal scale = qExp(-0.001 * event->delta());
     QPointF center = m_window.center();
     QPointF delta = scale * (m_window.bottomRight() - center);
     m_window = QRectF(center - delta, center + delta);
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index f461dfef06c4f75750e3d92ce1c9954926bbee42..84063eb692374b6b0445a057608e5fcf128ecce6 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -1684,7 +1684,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
                     b++;
                     fx += fdx;
                 }
-            } else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || fabs(data->m22) < (1./8.)) { // scale up more than 8x
+            } else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x
                 int y1 = (fy >> 16);
                 int y2;
                 fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2);
@@ -1843,7 +1843,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
                 }
             }
         } else { //rotation
-            if (fabs(data->m11) > 8 || fabs(data->m22) > 8) {
+            if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) {
                 //if we are zooming more than 8 times, we use 8bit precision for the position.
                 while (b < end) {
                     int x1 = (fx >> 16);
@@ -2196,7 +2196,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
                     layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut);
                     layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut);
 
-                    if ((fdx < 0 && fdx > -(fixed_scale / 8)) || fabs(data->m22) < (1./8.)) { // scale up more than 8x
+                    if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x
                         int disty = (fy & 0x0000ffff) >> 8;
                         for (int i = 0; i < len; ++i) {
                             uint tl = buf1[i * 2 + 0];
@@ -2255,7 +2255,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
                 layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut);
                 layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut);
 
-                if (fabs(data->m11) > 8 || fabs(data->m22) > 8) {
+                if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) {
                     //if we are zooming more than 8 times, we use 8bit precision for the position.
                     for (int i = 0; i < len; ++i) {
                         uint tl = buf1[i * 2 + 0];
diff --git a/src/gui/painting/qmath_p.h b/src/gui/painting/qmath_p.h
index 50a49c2cb58e6aa8698b0fae19b947bb0f4c40cd..9cb64a46cb57bc72156ca55c6fd74a4812cdb616 100644
--- a/src/gui/painting/qmath_p.h
+++ b/src/gui/painting/qmath_p.h
@@ -45,14 +45,13 @@
 // We mean it.
 //
 
-#include <math.h>
 #include <qmath.h>
 
 QT_BEGIN_NAMESPACE
 
-static const qreal Q_PI   = qreal(3.14159265358979323846);   // pi
-static const qreal Q_2PI  = qreal(6.28318530717958647693);   // 2*pi
-static const qreal Q_PI2  = qreal(1.57079632679489661923);   // pi/2
+static const qreal Q_PI   = qreal(M_PI);     // pi
+static const qreal Q_2PI  = qreal(2 * M_PI); // 2*pi
+static const qreal Q_PI2  = qreal(M_PI_2);   // pi/2
 static const qreal Q_MM_PER_INCH = 25.4;
 
 inline int qIntSqrtInt(int v)
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 426dd846ed74f3dce44525ae248eb29bb5e96f5c..75bf31cde157a16725f327aa567c96df635e0e64 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -712,20 +712,10 @@ static inline bool q26Dot6Compare(qreal p1, qreal p2)
     return int((p2  - p1) * 64.) == 0;
 }
 
-static inline qreal qFloorF(qreal v)
-{
-#ifdef QT_USE_MATH_H_FLOATS
-    if (sizeof(qreal) == sizeof(float))
-        return floorf(v);
-    else
-#endif
-        return floor(v);
-}
-
 static inline QPointF snapTo26Dot6Grid(const QPointF &p)
 {
-    return QPointF(qFloorF(p.x() * 64) * (1 / qreal(64)),
-                   qFloorF(p.y() * 64) * (1 / qreal(64)));
+    return QPointF(std::floor(p.x() * 64) * (1 / qreal(64)),
+                   std::floor(p.y() * 64) * (1 / qreal(64)));
 }
 
 /*
@@ -832,7 +822,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width,
             return;
 
         // adjust width which is given relative to |b - a|
-        width *= sqrt(w0 / w);
+        width *= qSqrt(w0 / w);
     }
 
     QSpanBuffer buffer(d->blend, d->data, d->clipRect);
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 49ec31fc19d54d8550b479994e682d344270e12f..471a39a6e1ba22f6ba3be24ae35336b900f833f5 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -509,8 +509,8 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
         bits[i] = exteriorColor;
 
     const qreal angleStep = qreal(15 * 3.141592653589793238 / 180);
-    const QPoint rotation(qRound(cos(angleStep) * 0x4000),
-                          qRound(sin(angleStep) * 0x4000)); // 2:14 signed
+    const QPoint rotation(qRound(qCos(angleStep) * 0x4000),
+                          qRound(qSin(angleStep) * 0x4000)); // 2:14 signed
 
     const quint32 *indices = pathIndices.data();
     QVarLengthArray<QPoint> normals;
@@ -544,7 +544,7 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
             QPoint n(to.y() - from.y(), from.x() - to.x());
             if (n.x() == 0 && n.y() == 0)
                 continue;
-            int scale = qRound((offs << 16) / sqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16
+            int scale = qRound((offs << 16) / qSqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16
             n.rx() = n.x() * scale >> 8;
             n.ry() = n.y() * scale >> 8;
             normals.append(n);
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 211b8b6659f1d8745ce147e20aec8416b7d3290b..1cdbf6aa8ec4ed3b32fe34655937120d6401715e 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2640,7 +2640,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
     QFontDef req = d->request;
 
     if (req.pixelSize == -1) {
-        req.pixelSize = floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;
+        req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;
         req.pixelSize = qRound(req.pixelSize);
     }
     if (req.pointSize < 0)
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp
index 5b98001b38816c40d7270b2cc2805a596a69e501..df8dab2903152366ba7fa5746574fac286902cda 100644
--- a/src/gui/util/qgridlayoutengine.cpp
+++ b/src/gui/util/qgridlayoutengine.cpp
@@ -193,7 +193,7 @@ namespace {
 // does not return int
 static inline qreal qround(qreal f)
 {
-    return floor(f + 0.5);
+    return std::floor(f + qreal(0.5));
 }
 
 }
@@ -355,7 +355,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
                     qreal maxBoxSize = box.q_maximumSize;
 
                     if (snapToPixelGrid)
-                        maxBoxSize = qMax(box.q_minimumSize, floor(maxBoxSize));
+                        maxBoxSize = qMax(box.q_minimumSize, std::floor(maxBoxSize));
 
                     qreal avail = sumCurrentAvailable * factors[i] / sumFactors;
                     if (sizes[i] + avail >= maxBoxSize) {
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index dcb1f9817f7a06ca14abcaaa7ad206afdd87fc16..6b1e20c844851a8c3765839628b6261ae4ff074a 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -40,7 +40,7 @@
 #include "private/qlocale_p.h"
 
 #include <limits.h>
-#include <math.h>
+#include <cmath>
 
 QT_BEGIN_NAMESPACE
 
@@ -384,7 +384,7 @@ static int numDigits(qlonglong n)
 {
     if (n == 0)
         return 1;
-    return (int)log10(double(n)) + 1;
+    return (int)std::log10(double(n)) + 1;
 }
 
 static qlonglong pow10(int exp)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 69bd0804775a0dc637d9abbebd988d8273cfaea4..e461dd0fd43fffc0baeb2a7a1febad9f06427701 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -400,8 +400,8 @@ void QGL2PaintEngineExPrivate::updateMatrix()
     // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.
     if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
         // 0.50 needs to rounded down to 0.0 for consistency with raster engine:
-        dx = ceilf(dx - 0.5f);
-        dy = ceilf(dy - 0.5f);
+        dx = std::ceil(dx - 0.5f);
+        dy = std::ceil(dy - 0.5f);
     }
     pmvMatrix[0][0] = (wfactor * transform.m11())  - transform.m13();
     pmvMatrix[1][0] = (wfactor * transform.m21())  - transform.m23();
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 3485c9a558fc29d7489746ee80b2449d9c4fac85..123a2c4c796ff52e3b663e3ec81c16cbb91ee6dc 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -39,9 +39,11 @@
 
 #include <private/qimage_p.h>
 
+#include <cmath>
+
 QT_BEGIN_NAMESPACE
 
-static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
+static float SYNTHETIC_ITALIC_SKEW = std::tan(14.f * std::acos(0.f) / 90.f);
 
 bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length)
 {
diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
index 2df4c588cc7347d67b598a7e6aa39c1ba7521731..16eb281a2f8776073e1709bf1eb3dda4d8aea468 100644
--- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
@@ -654,11 +654,11 @@ QCoreGraphicsPaintEngine::updateState(const QPaintEngineState &state)
                 d->cosmeticPenSize = 1.0;
         } else {
             d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticSetPenWidth;
-            static const float sqrt2 = sqrt(2);
+            static const float sqrt2 = std::sqrt(2.0f);
             qreal width = d->current.pen.widthF();
             if (!width)
                 width = 1;
-            d->cosmeticPenSize = sqrt(pow(d->pixelSize.y(), 2) + pow(d->pixelSize.x(), 2)) / sqrt2 * width;
+            d->cosmeticPenSize = std::sqrt(std::pow(d->pixelSize.y(), 2) + std::pow(d->pixelSize.x(), 2)) / sqrt2 * width;
         }
     }
 }
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 1818d614fd9962cc4c941908fe3d9875d34a7b4f..7b871be01511ca1a828fe53a1900e255b5db5bb0 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -455,10 +455,10 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
             // X Tilt = arctan(X / Z)
             // Y Tilt = arctan(Y / Z)
             const double radAzim = (packet.pkOrientation.orAzimuth / 10.0) * (M_PI / 180);
-            const double tanAlt = tan((abs(packet.pkOrientation.orAltitude / 10.0)) * (M_PI / 180));
+            const double tanAlt = std::tan((std::abs(packet.pkOrientation.orAltitude / 10.0)) * (M_PI / 180));
 
-            const double degX = atan(sin(radAzim) / tanAlt);
-            const double degY = atan(cos(radAzim) / tanAlt);
+            const double degX = std::atan(std::sin(radAzim) / tanAlt);
+            const double degY = std::atan(std::cos(radAzim) / tanAlt);
             tiltX = int(degX * (180 / M_PI));
             tiltY = int(-degY * (180 / M_PI));
             rotation = 360.0 - (packet.pkOrientation.orTwist / 10.0);
diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp
index c9e16205f0c7fc0d10277ea25b7d81adcc19aa01..b6ec54997b66a40746a9049b3bd62be228669faf 100644
--- a/src/widgets/widgets/qdial.cpp
+++ b/src/widgets/widgets/qdial.cpp
@@ -136,9 +136,9 @@ void QDial::initStyleOption(QStyleOptionSlider *option) const
 int QDialPrivate::valueFromPoint(const QPoint &p) const
 {
     Q_Q(const QDial);
-    double yy = (double)q->height()/2.0 - p.y();
-    double xx = (double)p.x() - q->width()/2.0;
-    double a = (xx || yy) ? qAtan2(yy, xx) : 0;
+    double yy = q->height()/2.0 - p.y();
+    double xx = p.x() - q->width()/2.0;
+    double a = (xx || yy) ? std::atan2(yy, xx) : 0;
 
     if (a < Q_PI / -2)
         a = a + Q_PI * 2;