本文整理汇总了C++中qIsNaN函数的典型用法代码示例。如果您正苦于以下问题:C++ qIsNaN函数的具体用法?C++ qIsNaN怎么用?C++ qIsNaN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qIsNaN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qIsNaN
int OsmAnd::Utilities::javaDoubleCompare(double l, double r)
{
const auto lNaN = qIsNaN(l);
const auto rNaN = qIsNaN(r);
const auto& li64 = *reinterpret_cast<uint64_t*>(&l);
const auto& ri64 = *reinterpret_cast<uint64_t*>(&r);
const auto lPos = (li64 >> 63) == 0;
const auto rPos = (ri64 >> 63) == 0;
const auto lZero = (li64 << 1) == 0;
const auto rZero = (ri64 << 1) == 0;
// NaN is considered by this method to be equal to itself and greater than all other double values (including +inf).
if (lNaN && rNaN)
return 0;
if (lNaN)
return +1;
if (rNaN)
return -1;
// 0.0 is considered by this method to be greater than -0.0
if (lZero && rZero)
{
if (lPos && !rPos)
return -1;
if (!lPos && rPos)
return +1;
}
// All other cases
return qCeil(l) - qCeil(r);
}
示例2: foreach
PointSegment *GcodeParser::processCommand(const QStringList &args)
{
QList<float> gCodes;
PointSegment *ps = NULL;
// Handle F code
double speed = GcodePreprocessorUtils::parseCoord(args, 'F');
if (!qIsNaN(speed)) this->m_lastSpeed = this->m_isMetric ? speed : speed * 25.4;
// Handle S code
double spindleSpeed = GcodePreprocessorUtils::parseCoord(args, 'S');
if (!qIsNaN(spindleSpeed)) this->m_lastSpindleSpeed = spindleSpeed;
// Handle P code
double dwell = GcodePreprocessorUtils::parseCoord(args, 'P');
if (!qIsNaN(dwell)) this->m_points.last()->setDwell(dwell);
// handle G codes.
gCodes = GcodePreprocessorUtils::parseCodes(args, 'G');
// If there was no command, add the implicit one to the party.
if (gCodes.isEmpty() && m_lastGcodeCommand != -1) {
gCodes.append(m_lastGcodeCommand);
}
foreach (float code, gCodes) {
ps = handleGCode(code, args);
}
示例3: box
void SearchReply::start()
{
if (request().searchArea().type() == QGeoShape::RectangleType) {
QGeoRectangle box(request().searchArea());
if (!box.isValid()) {
triggerDone(QPlaceReply::BadArgumentError,
QString::fromLatin1("Bounding box search area is invalid"));
return;
}
} else if (request().searchArea().type() == QGeoShape::CircleType) {
QGeoCircle circle(request().searchArea());
if (!circle.center().isValid() || qIsNaN(circle.center().latitude()) || qIsNaN(circle.center().longitude())) {
triggerDone(QPlaceReply::BadArgumentError,
QString::fromLatin1("The center of the search area is an invalid coordinate"));
return;
}
if (circle.contains(QGeoCoordinate(90,0)) || circle.contains(QGeoCoordinate(-90,0))) {
triggerDone(QPlaceReply::BadArgumentError,
QString::fromLatin1("The search area contains the north or south pole"));
return;
}
}
if (!request().categories().isEmpty()) {
foreach (const QPlaceCategory &category, request().categories()) {
m_catSearchIds.append(categorySearchIds(category.categoryId()));
db()->searchForPlaces(request(), this, SLOT(searchFinished()), m_catSearchIds);
}
} else {
示例4: QSKIP
void tst_QNumeric::qNan()
{
#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404)
QSKIP("Non-conformant fast math mode is enabled, cannot run test");
#endif
double nan = qQNaN();
QVERIFY(!(0 > nan));
QVERIFY(!(0 < nan));
QVERIFY(qIsNaN(nan));
QVERIFY(qIsNaN(nan + 1));
QVERIFY(qIsNaN(-nan));
double inf = qInf();
QVERIFY(inf > 0);
QVERIFY(-inf < 0);
QVERIFY(qIsInf(inf));
QVERIFY(qIsInf(-inf));
QVERIFY(qIsInf(2*inf));
QCOMPARE(1/inf, 0.0);
#ifdef Q_CC_INTEL
QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue);
#endif
QVERIFY(qIsNaN(0*nan));
#ifdef Q_CC_INTEL
QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue);
#endif
QVERIFY(qIsNaN(0*inf));
QVERIFY(qFuzzyCompare(1/inf, 0.0));
}
示例5: Q_UNUSED
void QgsSingleBandGrayRendererWidget::loadMinMax( int theBandNo, double theMin, double theMax )
{
Q_UNUSED( theBandNo );
QgsDebugMsg( QString( "theBandNo = %1 theMin = %2 theMax = %3" ).arg( theBandNo ).arg( theMin ).arg( theMax ) );
mDisableMinMaxWidgetRefresh = true;
if ( qIsNaN( theMin ) )
{
mMinLineEdit->clear();
}
else
{
mMinLineEdit->setText( QString::number( theMin ) );
}
if ( qIsNaN( theMax ) )
{
mMaxLineEdit->clear();
}
else
{
mMaxLineEdit->setText( QString::number( theMax ) );
}
mDisableMinMaxWidgetRefresh = false;
}
示例6: find_part
/*!
\qmlmethod point QtLocation::Map::from_coordinate(coordinate coordinate, bool clipToViewPort)
Returns the position relative to the map item which corresponds to the \a coordinate.
If \a cliptoViewPort is \c true, or not supplied then returns an invalid QPointF if
\a coordinate is not within the current viewport.
*/
QcVectorDouble
QcViewport::coordinate_to_screen(const QcVectorDouble & projected_coordinate, bool clip_to_viewport) const
{
// qInfo() << coordinate << clip_to_viewport
// << (int)projected_coordinate.x() << (int)projected_coordinate.y();
const QcViewportPart * part = find_part(projected_coordinate);
if (!part) {
qWarning() << "out of domain";
return QcVectorDouble(qQNaN(), qQNaN());
}
QcVectorDouble screen_position = to_px(part->map_vector(projected_coordinate));
// Fixme: purpose
if (clip_to_viewport) {
int w = width();
int h = height();
double x = screen_position.x();
double y = screen_position.y();
if ((x < 0.0) || (x > w) || (y < 0) || (y > h) || qIsNaN(x) || qIsNaN(y))
return QcVectorDouble(qQNaN(), qQNaN());
}
// qInfo() << screen_position;
return screen_position;
}
示例7: qQNaN
void tst_QNumeric::qNan()
{
double nan = qQNaN();
#if defined( __INTEL_COMPILER)
QCOMPARE((0 > nan), false);
QCOMPARE((0 < nan), false);
QSKIP("This fails due to a bug in the Intel Compiler", SkipAll);
#else
if (0 > nan)
QFAIL("compiler thinks 0 > nan");
# if defined(Q_CC_DIAB)
QWARN("!(0 < nan) would fail due to a bug in dcc");
# else
if (0 < nan)
QFAIL("compiler thinks 0 < nan");
# endif
#endif
QVERIFY(qIsNaN(nan));
QVERIFY(qIsNaN(nan + 1));
QVERIFY(qIsNaN(-nan));
double inf = qInf();
QVERIFY(inf > 0);
QVERIFY(-inf < 0);
QVERIFY(qIsInf(inf));
QVERIFY(qIsInf(-inf));
QVERIFY(qIsInf(2*inf));
QCOMPARE(1/inf, 0.0);
QVERIFY(qIsNaN(0*nan));
QVERIFY(qIsNaN(0*inf));
QVERIFY(qFuzzyCompare(1/inf, 0.0));
}
示例8: alphaValue
/**
Searches through the transparency list, if a match is found, the global transparency value is scaled
by the stored transparency value.
@param theRedValue the red portion of the needle to search for in the transparency hay stack
@param theGreenValue the green portion of the needle to search for in the transparency hay stack
@param theBlueValue the green portion of the needle to search for in the transparency hay stack
@param theGlobalTransparency the overal transparency level for the layer
*/
int QgsRasterTransparency::alphaValue( double theRedValue, double theGreenValue, double theBlueValue, int theGlobalTransparency ) const
{
//if NaN return 0, transparent
if ( qIsNaN( theRedValue ) || qIsNaN( theGreenValue ) || qIsNaN( theBlueValue ) )
{
return 0;
}
//Search through the transparency list looking for a match
bool myTransparentPixelFound = false;
TransparentThreeValuePixel myTransparentPixel = {0, 0, 0, 100};
for ( int myListRunner = 0; myListRunner < mTransparentThreeValuePixelList.count(); myListRunner++ )
{
myTransparentPixel = mTransparentThreeValuePixelList[myListRunner];
if ( myTransparentPixel.red == theRedValue )
{
if ( myTransparentPixel.green == theGreenValue )
{
if ( myTransparentPixel.blue == theBlueValue )
{
myTransparentPixelFound = true;
break;
}
}
}
}
//if a match was found use the stored transparency percentage
if ( myTransparentPixelFound )
{
return ( int )(( float )theGlobalTransparency *( 1.0 - ( myTransparentPixel.percentTransparent / 100.0 ) ) );
}
return theGlobalTransparency;
}
示例9: qIsNaN
bool QPlaceResultPrivate::compare(const QPlaceSearchResultPrivate *other) const
{
const QPlaceResultPrivate *od = static_cast<const QPlaceResultPrivate *>(other);
return QPlaceSearchResultPrivate::compare(other)
&& ((qIsNaN(distance) && qIsNaN(od->distance))
|| qFuzzyCompare(distance, od->distance))
&& place == od->place
&& sponsored == od->sponsored;
}
示例10: reload
void GeoReverseGeocode::reload()
{
if (qIsNaN(latitude())) return;
if (qIsNaN(longitude())) return;
if (qFuzzyCompare(latitude(), 0.0)) return;
if (qFuzzyCompare(longitude(), 0.0)) return;
AbstractTwitterModel::reload();
}
示例11: eraseLineTo
void UBWidgetUniboardAPI::eraseLineTo(const qreal x, const qreal y, const qreal pWidth)
{
if (qIsNaN(x) || qIsNaN(y) || qIsNaN(pWidth)
|| qIsInf(x) || qIsInf(y) || qIsInf(pWidth))
return;
if (mScene)
mScene->eraseLineTo(QPointF(x, y), pWidth);
}
示例12: moveTo
void UBWidgetUniboardAPI::moveTo(const qreal x, const qreal y)
{
if (qIsNaN(x) || qIsNaN(y)
|| qIsInf(x) || qIsInf(y))
return;
if (mScene)
mScene->moveTo(QPointF(x, y));
}
示例13: fix
void Test_ATCAbstractFix::test_constructObject_incorrectLat()
{
Mock_ATCAbstractFix fix(-91, 50);
QVERIFY(qIsNaN(fix.latitude()));
QVERIFY(qIsNaN(fix.longitude()));
fix = Mock_ATCAbstractFix(91, 50);
QVERIFY(qIsNaN(fix.latitude()));
QVERIFY(qIsNaN(fix.longitude()));
}
示例14: drawLineTo
void UBWidgetUniboardAPI::drawLineTo(const qreal x, const qreal y, const qreal pWidth)
{
if (qIsNaN(x) || qIsNaN(y) || qIsNaN(pWidth)
|| qIsInf(x) || qIsInf(y) || qIsInf(pWidth))
return;
if (mScene)
mScene->drawLineTo(QPointF(x, y), pWidth,
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
}
示例15: resize
void UBWidgetUniboardAPI::resize(qreal width, qreal height)
{
if (qIsNaN(width) || qIsNaN(height)
|| qIsInf(width) || qIsInf(height))
return;
if (mGraphicsWidget)
{
mGraphicsWidget->resize(width, height);
}
}