Bug report #12947

qgsDoubleToString in Qgis.h error

Added by Fabio Cosimelli about 9 years ago. Updated about 9 years ago.

Status:Closed
Priority:High
Assignee:-
Category:-
Affected QGIS version:2.8.2 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21027

Description

If precision is 0 the number 12000 becomes "12", probably the solution is:

inline QString qgsDoubleToString( const double &a, const int &precision = 17 ) {
if(precision)
return QString::number( a, 'f', precision ).remove( QRegExp( "\\\\.?0+$" ) );
else
return QString::number( a, 'f', precision );
}

Associated revisions

Revision ac38b213
Added by Matthias Kuhn about 9 years ago

qgsDoubleToString: Don't remove trailing zeros when integer

+ added testcase

Fix #12947

Revision 43569eff
Added by Matthias Kuhn about 9 years ago

qgsDoubleToString: Don't remove trailing zeros when integer

Fix #12947

cherry-picked from ac38b21380

Backported to 2.8.3

History

#1 Updated by Giovanni Manghi about 9 years ago

  • Status changed from Open to Feedback

better submit a patch as a pull request on github?

#2 Updated by Matthias Kuhn about 9 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF