Skip to content

Commit

Permalink
Introduce qgsRound since std::round is available only in C++11 onwards
Browse files Browse the repository at this point in the history
(cherry-picked from 468012a)
  • Loading branch information
nyalldawson committed Nov 19, 2015
1 parent f16328a commit 3ffdb6c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/qgis.h
Expand Up @@ -351,6 +351,14 @@ inline bool qgsDoubleNearSig( double a, double b, int significantDigits = 10 )
qRound( ar * pow( 10.0, significantDigits ) ) == qRound( br * pow( 10.0, significantDigits ) );
}

//
// a round function which returns a double to guard against overflows
//
inline double qgsRound( double x )
{
return x < 0.0 ? std::ceil( x - 0.5 ) : std::floor( x + 0.5 );
}

bool qgsVariantLessThan( const QVariant& lhs, const QVariant& rhs );

bool qgsVariantGreaterThan( const QVariant& lhs, const QVariant& rhs );
Expand Down

0 comments on commit 3ffdb6c

Please sign in to comment.