Skip to content

Commit

Permalink
use qRound() for round()
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Aug 29, 2012
1 parent f006b23 commit ad437bf
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@
#include "qgsgeometry.h"
#include "qgslogger.h"

//non qt includes
#include <cmath>

#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

// from parser
extern QgsExpression::Node* parseExpression( const QString& str, QString& parserErrorMsg );

Expand Down Expand Up @@ -782,13 +775,13 @@ static QVariant fcnRound( const QVariantList& values , QgsFeature *f, QgsExpress
{
double number = getDoubleValue( values.at( 0 ), parent );
double scaler = pow( 10.0, getIntValue( values.at( 1 ), parent ) );
return QVariant( round( number * scaler ) / scaler );
return QVariant( qRound( number * scaler ) / scaler );
}

if ( values.length() == 1 )
{
double number = getIntValue( values.at( 0 ), parent );
return QVariant( round( number) ).toInt();
return QVariant( qRound( number) ).toInt();
}

return QVariant();
Expand Down

0 comments on commit ad437bf

Please sign in to comment.