Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnumeric.h File Reference

(0677d334f85f6d39f6f6495162eec69712e42370)

#include <QtCore/qtconfigmacros.h>
#include <QtCore/qtcoreexports.h>
#include <QtCore/qtypes.h>
#include <cmath>
#include <limits>
#include <type_traits>
+ Include dependency graph for qnumeric.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  QtPrivate
 \macro QT_NO_KEYWORDS >
 

Macros

#define Q_INFINITY   (QT_PREPEND_NAMESPACE(qInf)())
 
#define Q_QNAN   (QT_PREPEND_NAMESPACE(qQNaN)())
 

Functions

template<typename T >
QT_BEGIN_NAMESPACE constexpr std::enable_if< std::is_integral< T >::value, bool >::type qIsInf (T)
 
template<typename T >
constexpr std::enable_if< std::is_integral< T >::value, bool >::type qIsNaN (T)
 
template<typename T >
constexpr std::enable_if< std::is_integral< T >::value, bool >::type qIsFinite (T)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsInf (double d)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsNaN (double d)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsFinite (double d)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION int qFpClassify (double val)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsInf (float f)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsNaN (float f)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsFinite (float f)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION int qFpClassify (float val)
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN ()
 
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf ()
 
Q_CORE_EXPORT quint32 qFloatDistance (float a, float b)
 
Q_CORE_EXPORT quint64 qFloatDistance (double a, double b)
 
template<typename T >
std::enable_if_t< std::is_unsigned_v< T >, bool > qAddOverflow (T v1, T v2, T *r)
 
template<typename T >
std::enable_if_t< std::is_signed_v< T >, bool > qAddOverflow (T v1, T v2, T *r)
 
template<typename T >
std::enable_if_t< std::is_unsigned_v< T >, bool > qSubOverflow (T v1, T v2, T *r)
 
template<typename T >
std::enable_if_t< std::is_signed_v< T >, bool > qSubOverflow (T v1, T v2, T *r)
 
template<typename T >
std::enable_if_t< std::is_unsigned_v< T >||std::is_signed_v< T >, bool > qMulOverflow (T v1, T v2, T *r)
 
template<typename T , T V2>
bool qAddOverflow (T v1, std::integral_constant< T, V2 >, T *r)
 
template<auto V2, typename T >
bool qAddOverflow (T v1, T *r)
 
template<typename T , T V2>
bool qSubOverflow (T v1, std::integral_constant< T, V2 >, T *r)
 
template<auto V2, typename T >
bool qSubOverflow (T v1, T *r)
 
template<typename T , T V2>
bool qMulOverflow (T v1, std::integral_constant< T, V2 >, T *r)
 
template<auto V2, typename T >
bool qMulOverflow (T v1, T *r)
 
template<typename T >
constexpr T qAbs (const T &t)
 
constexpr int qRound (double d)
 
constexpr int qRound (float d)
 
constexpr qint64 qRound64 (double d)
 
constexpr qint64 qRound64 (float d)
 
template<typename T >
constexpr const T & QtPrivate::min (const T &a, const T &b)
 
constexpr bool qFuzzyCompare (double p1, double p2)
 
constexpr bool qFuzzyCompare (float p1, float p2)
 
constexpr bool qFuzzyIsNull (double d)
 
constexpr bool qFuzzyIsNull (float f)
 
QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE constexpr bool qIsNull (double d) noexcept
 
constexpr bool qIsNull (float f) noexcept
 
QT_WARNING_POP int qIntCast (double f)
 
int qIntCast (float f)
 

Macro Definition Documentation

◆ Q_INFINITY

◆ Q_QNAN

#define Q_QNAN   (QT_PREPEND_NAMESPACE(qQNaN)())

Definition at line 81 of file qnumeric.h.

Referenced by QScrollerPrivate::nextSnapPos().

Function Documentation

◆ qAbs()

template<typename T >
constexpr T qAbs ( const T & t)
inlineconstexpr

Definition at line 328 of file qnumeric.h.

Referenced by QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), QtPrivate::QMovableArrayOps< T >::Inserter::~Inserter(), QGraphicsSceneBspTreeIndexPrivate::_q_updateIndex(), QtPrivate::QHypotHelper< T >::add(), QBezier::addToPolygon(), QBezier::addToPolygon(), QQuick3DParticleScaleAffector::affectParticle(), QQuickWanderAffector::affectParticle(), QAndroidCameraSession::applyResolution(), QIBaseResult::applyScale(), QQuickContext2D::arc(), avfVideoSettings(), QSSGBounds3::basisExtent(), bestSizeScaleMatch(), bestStyle(), QWaylandInputMethodEventBuilder::buildCommit(), QV4DataCollector::buildFrame(), QQuickPathViewPrivate::calcCurrentIndex(), QSpinBoxPrivate::calculateAdaptiveDecimalStep(), QDoubleSpinBoxPrivate::calculateAdaptiveDecimalStep(), calculateVideoFrameStride(), QuickTestUtil::callerLine(), QV4::ExecutionEngine::catchExceptionAsQmlError(), QGeoTiledMapPrivate::changeCameraData(), QQuickDeliveryAgentPrivate::checkIfDoubleTapped(), QWidgetWindowPrivate::closestAcceptableGeometry(), QListViewPrivate::closestIndex(), QQuickVisualTestUtils::compareImages(), computeBBox(), QFreetypeFace::computeSize(), QSSGPlane::contains(), convertPath(), convertWeights(), QWebMercator::coordinateInterpolation(), copyImageData(), createPixmapCursorFromData(), QQuickSwipePrivate::createRelevantItemForDistance(), QScrollerPrivate::createScrollingSegments(), QV4DebuggerAgent::debuggerPaused(), QCoreGraphicsPaintEnginePrivate::devicePixelSize(), directorySizeDistance(), do_write_jpeg_image(), QLocaleData::doubleToString(), QQuickDeliveryAgentPrivate::dragOverThreshold(), QQuickPointerHandlerPrivate::dragOverThreshold(), QQuickDeliveryAgentPrivate::dragOverThreshold(), QQuickDeliveryAgentPrivate::dragOverThreshold(), QQuickPointerHandlerPrivate::dragOverThreshold(), QPainterPrivate::draw_helper(), QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(), QRasterPaintEngine::drawImage(), drawLine(), drawLineAA(), QWin32PrintEngine::drawPixmap(), QRasterPaintEngine::drawTiledPixmap(), dtoString(), QQuickDrawerPrivate::effectiveEdge(), epsilonCompare(), QColorSpacePrivate::equals(), QJSEngine::evaluate(), QGeoRectanglePrivate::extendRectangle(), FDot16FixedDiv(), fetchTransformedBilinear(), fetchTransformedBilinear_simple_scale_helper(), fetchTransformedBilinearARGB32PM(), fetchTransformedBilinearARGB32PM_simple_scale_helper(), QRasterPlatformPixmap::fill(), QQuadPath::fillSideOf(), QQuickSwipePrivate::finishTransition(), QQuickGridViewPrivate::fixup(), QQuickListViewPrivate::fixup(), QQuickFlickablePrivate::flick(), QQuickGridViewPrivate::flick(), QQuickListViewPrivate::flick(), QBackingStore::flush(), QLocale::formattedDataSize(), QWindowsGeometryHint::frame(), QWindowsGeometryHint::frameOnPrimaryScreen(), QVideoFrameFormatPrivate::frameRatesEqual(), QOCIDateTime::fromOCIDateTime(), QuickTestResult::fuzzyCompare(), QQuickMatrix4x4ValueType::fuzzyEquals(), QQuickQuaternionValueType::fuzzyEquals(), QQuickVector2DValueType::fuzzyEquals(), QQuickVector3DValueType::fuzzyEquals(), QQuickVector4DValueType::fuzzyEquals(), fuzzyIsNull(), QPdfDocument::getSelection(), good_offset(), QQuickDrawerPrivate::grabMouse(), QScrollerPrivate::handleDrag(), QQuickPathViewPrivate::handleMouseMoveEvent(), QQuickPathViewPrivate::handleMousePressEvent(), QQuickPathViewPrivate::handleMouseReleaseEvent(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), QQuickRangeSliderPrivate::handlePress(), QQuickFlickablePrivate::handlePressEvent(), QQuickFlickablePrivate::handleReleaseEvent(), QPdfDocumentPrivate::hitTest(), QColorSpacePrivate::identifyColorSpace(), imageFromWinHBITMAP_GetDiBits(), QCoreTextFontEngine::init(), QWaylandQtTextInputMethod::inputMethodQuery(), QWaylandTextInputPrivate::inputMethodQuery(), QWaylandTextInputV3Private::inputMethodQuery(), QSSGClipPlane::intersectWithLine(), QQuickDialPrivate::isLargeChange(), QIntersectionPoint::isOnLine(), QQuickContext2D::isPointInPath(), QSSGUtils::quat::isSane(), QSimplexConstraint::isSatisfied(), QSSGUtils::quat::isUnit(), QStroker::joinPoints(), jsStack(), QTextDocumentLayoutPrivate::layoutFlow(), QWindowsFontDatabaseBase::LOGFONT_to_QFont(), QPoint::manhattanLength(), QPointF::manhattanLength(), QDoubleVector2D::manhattanLength(), QScanConverter::mergeCurve(), QV4::DatePrototype::method_toISOString(), QFontEngine::minRightBearing(), QHeaderView::mouseMoveEvent(), QQuickPressHandler::mouseMoveEvent(), QQuickTextInput::mouseMoveEvent(), QTabBar::mouseReleaseEvent(), QAbstractButtonPrivate::moveFocus(), QToolBarAreaLayoutInfo::moveToolBar(), QScrollerPrivate::moveWhilePressed(), QScrollerPrivate::nextSnapPos(), operator<<(), QTextEditPrivate::pageUpDown(), QGraphicsEllipseItem::paint(), QQuickSvgParser::pathArc(), pathArc(), QTriangulator< T >::polyline(), QMenuSloppyState::processMouseEvent(), QGuiApplicationPrivate::processMouseEvent(), q_coordinateShortestInterpolator(), qFuzzyCompare(), qFuzzyCompare(), qFuzzyCompare(), qFuzzyIsNull(), qFuzzyIsNull(), qFuzzyIsNull(), QImageScale::qimageCalcScaleInfo(), QImageScale::qimageCalcXPoints(), QImageScale::qimageCalcYPoints(), qRealToFraction(), qt_create_image_data(), qt_device_format_pixel_aspect_ratio(), qt_find_best_framerate_match(), qt_find_best_resolution_match(), qt_find_supported_framerate_range(), qt_scaleForTransform(), qt_scrollRectInImage(), QCoreTextFontEngine::qtWeightFromCFWeight(), QRasterizer::rasterizeLine(), read_dib_infoheader(), QSwipeGestureRecognizer::recognize(), QIBaseResult::record(), QIBaseDriver::record(), AndroidPositioning::registerPositionInfoSource(), QtConcurrent::ThreadEngineBarrier::release(), QtConcurrent::ThreadEngineBarrier::releaseUnlessLast(), QProgressBarPrivate::repaintRequired(), replaceArgEscapes(), QWindowsTabletDeviceData::scaleCoordinates(), QTreeView::scrollContentsBy(), QQuickTableViewPrivate::scrollToColumn(), QQuickTableViewPrivate::scrollToRow(), QTreeViewPrivate::select(), QWidgetTextControl::selectAll(), QQuickTextControl::selectAll(), Utils::TextCursor::selectedText(), QWaylandTextInputPrivate::sendInputMethodEvent(), QSimplex::setConstraints(), QQuickTextPrivate::setLineGeometry(), QQuickDialPrivate::setPosition(), QMacPrintEngine::setProperty(), QAbstractSliderPrivate::setSteps(), setupCameraForShadowMap(), QSpanData::setupMatrix(), QPen::setWidthF(), QPaintEngineEx::shouldDrawCachedGlyphs(), QQuickPathViewPrivate::snapToIndex(), QBezier::tAtLength(), QDoubleSpinBox::textFromValue(), QSpinBox::textFromValue(), QtAndroidAccessibility::textFromValue(), QBezier::tForY(), toOffsetString(), QGeoCoordinate::toString(), QX11PlatformPixmap::transformed(), QQuickSpringAnimation::transition(), QTriangulator< T >::triangulate(), QLineF::unitVector(), updateBBox(), QSpringAnimation::updateCurrentTime(), QQuickBoundaryReturnJob::updateCurrentTime(), QSGBasicInternalImageNode::updateGeometry(), QSGBasicInternalImageNode::updateGeometry(), QOpenGL2PaintEngineExPrivate::updateMatrix(), QRasterPaintEnginePrivate::updateMatrixData(), QQuickSpringAnimationPrivate::updateMode(), QQuickRectangle::updatePaintNode(), QQuickShaderEffectSource::updatePaintNode(), QSpatialSoundPrivate::updateRoomEffects(), QAudioEnginePrivate::updateRooms(), QQuick3DTexture::updateSpatialNode(), QtWaylandClient::QWaylandTextInputv1::updateState(), QtWaylandClient::QWaylandTextInputv2::updateState(), QQuickMultiPointTouchArea::updateTouchData(), QT_BEGIN_NAMESPACE::QSGCurveFillMaterialShader::updateUniformData(), QSGCurveStrokeMaterialShader::updateUniformData(), QSGDistanceFieldTextMaterialRhiShader::updateUniformData(), v4StackTrace(), QIntValidator::validate(), QDoubleValidatorPrivate::validateWithLocale(), AVFMediaPlayer::videoOrientationForAssetTrack(), QQuickFlickablePrivate::viewportAxisMoved(), QGeoProjectionWebMercator::visibleRegion(), QQuickFlickable::xflick(), QTextLine::xToCursor(), and QQuickFlickable::yflick().

◆ qAddOverflow() [1/4]

template<typename T , T V2>
template< typename T, T V2 > bool qAddOverflow ( T v1,
std::integral_constant< T, V2 > ,
T * r )
Since
6.1

Equivalent to qAddOverflow(v1, v2, r) with v1 as first argument, the compile time constant V2 as second argument, and r as third argument.

Definition at line 253 of file qnumeric.h.

References qAddOverflow().

+ Here is the call graph for this function:

◆ qAddOverflow() [2/4]

template<auto V2, typename T >
template< auto V2, typename T > bool qAddOverflow ( T v1,
T * r )
Since
6.1

Equivalent to qAddOverflow(v1, v2, r) with v1 as first argument, the compile time constant V2 as second argument, and r as third argument.

Definition at line 258 of file qnumeric.h.

References qAddOverflow().

+ Here is the call graph for this function:

◆ qAddOverflow() [3/4]

◆ qAddOverflow() [4/4]

template<typename T >
std::enable_if_t< std::is_signed_v< T >, bool > qAddOverflow ( T v1,
T v2,
T * r )
inline

Definition at line 121 of file qnumeric.h.

References s2.

◆ qFloatDistance() [1/2]

Q_CORE_EXPORT quint64 qFloatDistance ( double a,
double b )

◆ qFloatDistance() [2/2]

Q_CORE_EXPORT quint32 qFloatDistance ( float a,
float b )

◆ qFpClassify() [1/2]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION int qFpClassify ( double val)

Definition at line 98 of file qnumeric.cpp.

References qt_fpclassify().

+ Here is the call graph for this function:

◆ qFpClassify() [2/2]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION int qFpClassify ( float val)

Definition at line 99 of file qnumeric.cpp.

References qt_fpclassify().

+ Here is the call graph for this function:

◆ qFuzzyCompare() [1/2]

constexpr bool qFuzzyCompare ( double p1,
double p2 )
constexpr

Definition at line 369 of file qnumeric.h.

References QtPrivate::min(), p1, p2, and qAbs().

+ Here is the call graph for this function:

◆ qFuzzyCompare() [2/2]

constexpr bool qFuzzyCompare ( float p1,
float p2 )
constexpr

Definition at line 374 of file qnumeric.h.

References QtPrivate::min(), p1, p2, and qAbs().

+ Here is the call graph for this function:

◆ qFuzzyIsNull() [1/2]

constexpr bool qFuzzyIsNull ( double d)
constexpr

Definition at line 379 of file qnumeric.h.

References d, and qAbs().

+ Here is the call graph for this function:

◆ qFuzzyIsNull() [2/2]

constexpr bool qFuzzyIsNull ( float f)
constexpr

Definition at line 384 of file qnumeric.h.

References qAbs().

+ Here is the call graph for this function:

◆ qInf()

◆ qIntCast() [1/2]

QT_WARNING_POP int qIntCast ( double f)
inline

Definition at line 404 of file qnumeric.h.

◆ qIntCast() [2/2]

int qIntCast ( float f)
inline

Definition at line 405 of file qnumeric.h.

◆ qIsFinite() [1/3]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsFinite ( double d)

◆ qIsFinite() [2/3]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsFinite ( float f)

◆ qIsFinite() [3/3]

template<typename T >
constexpr std::enable_if< std::is_integral< T >::value, bool >::type qIsFinite ( T )
constexpr

Definition at line 56 of file qnumeric.h.

◆ qIsInf() [1/3]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsInf ( double d)

◆ qIsInf() [2/3]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsInf ( float f)

◆ qIsInf() [3/3]

template<typename T >
QT_BEGIN_NAMESPACE constexpr std::enable_if< std::is_integral< T >::value, bool >::type qIsInf ( T )
constexpr

Definition at line 50 of file qnumeric.h.

◆ qIsNaN() [1/3]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsNaN ( double d)

◆ qIsNaN() [2/3]

Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qIsNaN ( float f)

◆ qIsNaN() [3/3]

template<typename T >
constexpr std::enable_if< std::is_integral< T >::value, bool >::type qIsNaN ( T )
constexpr

Definition at line 53 of file qnumeric.h.

◆ qIsNull() [1/2]

QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE constexpr bool qIsNull ( double d)
constexprnoexcept

Definition at line 392 of file qnumeric.h.

References d.

◆ qIsNull() [2/2]

constexpr bool qIsNull ( float f)
constexprnoexcept

Definition at line 397 of file qnumeric.h.

◆ qMulOverflow() [1/3]

template<typename T , T V2>
template< typename T, T V2 > bool qMulOverflow ( T v1,
std::integral_constant< T, V2 > ,
T * r )
Since
6.1

Equivalent to qMulOverflow(v1, v2, r) with v1 as first argument, the compile time constant V2 as second argument, and r as third argument. This can be faster than calling the version with only variable arguments.

Definition at line 273 of file qnumeric.h.

References qMulOverflow(), and v1.

+ Here is the call graph for this function:

◆ qMulOverflow() [2/3]

template<auto V2, typename T >
template< auto V2, typename T > bool qMulOverflow ( T v1,
T * r )
Since
6.1

Equivalent to qMulOverflow(v1, v2, r) with v1 as first argument, the compile time constant V2 as second argument, and r as third argument. This can be faster than calling the version with only variable arguments.

Definition at line 320 of file qnumeric.h.

References qAddOverflow(), and qMulOverflow().

+ Here is the call graph for this function:

◆ qMulOverflow() [3/3]

template<typename T >
std::enable_if_t< std::is_unsigned_v< T >||std::is_signed_v< T >, bool > qMulOverflow ( T v1,
T v2,
T * r )
inline

◆ qQNaN()

◆ qRound() [1/2]

constexpr int qRound ( double d)
inlineconstexpr

Definition at line 353 of file qnumeric.h.

References d.

◆ qRound() [2/2]

constexpr int qRound ( float d)
inlineconstexpr

Definition at line 355 of file qnumeric.h.

References d.

◆ qRound64() [1/2]

constexpr qint64 qRound64 ( double d)
inlineconstexpr

Definition at line 358 of file qnumeric.h.

References d.

◆ qRound64() [2/2]

constexpr qint64 qRound64 ( float d)
inlineconstexpr

Definition at line 360 of file qnumeric.h.

References d.

◆ qSubOverflow() [1/4]

template<typename T , T V2>
template< typename T, T V2 > bool qSubOverflow ( T v1,
std::integral_constant< T, V2 > ,
T * r )
Since
6.1

Equivalent to qSubOverflow(v1, v2, r) with v1 as first argument, the compile time constant V2 as second argument, and r as third argument.

Definition at line 263 of file qnumeric.h.

References qSubOverflow().

+ Here is the call graph for this function:

◆ qSubOverflow() [2/4]

template<auto V2, typename T >
template< auto V2, typename T > bool qSubOverflow ( T v1,
T * r )
Since
6.1

Equivalent to qSubOverflow(v1, v2, r) with v1 as first argument, the compile time constant V2 as second argument, and r as third argument.

Definition at line 268 of file qnumeric.h.

References qSubOverflow().

+ Here is the call graph for this function:

◆ qSubOverflow() [3/4]

template<typename T >
std::enable_if_t< std::is_unsigned_v< T >, bool > qSubOverflow ( T v1,
T v2,
T * r )
inline

Definition at line 153 of file qnumeric.h.

Referenced by QDateTimePrivate::expressUtcAsLocal(), qSubOverflow(), qSubOverflow(), QTimeZonePrivate::stateAtZoneTime(), and QV4::sub_int32().

+ Here is the caller graph for this function:

◆ qSubOverflow() [4/4]

template<typename T >
std::enable_if_t< std::is_signed_v< T >, bool > qSubOverflow ( T v1,
T v2,
T * r )
inline

Definition at line 161 of file qnumeric.h.

References s2.