Bug report #20861

Function "round" in expressions assumes a strange behavior on negative numbers when the parameter "places" is assigned.

Added by Gabriel De Luca about 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:Loïc BARTOLETTI
Category:Expressions
Affected QGIS version:3.5(master) Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:28680

Description

Function "round" in expressions assumes a strange behavior on negative numbers when the parameter "places" is assigned.

Tested on attributes of type "Decimal number (real)".

It does not happen when applied to positive numbers or when the "places" parameter is not specified.

Tested on QGIS 3.4.2, Windows 10, with all plugins disabled or not.

Associated revisions

Revision cfdc8c26
Added by Loïc BARTOLETTI almost 6 years ago

[BUGFIX] fix qgsRound for negative numbers. Fixes #20861

Revision 3f0171b8
Added by Loïc BARTOLETTI almost 6 years ago

[BUGFIX] fix qgsRound for negative numbers. Fixes #20861

(cherry picked from commit cfdc8c26c29baaf4a62c9a94df9208dff3f6beda)

History

#1 Updated by Loïc BARTOLETTI almost 6 years ago

  • Operating System deleted (Windows 10)
  • Affected QGIS version changed from 3.4.2 to 3.5(master)
  • Assignee set to Loïc BARTOLETTI
  • Status changed from Open to Feedback

Can you describe the problem more precisely by including the treatment involved and the expected outcome.

For my part, I observed a problem with rounding, e. g:

round(-1234.567, 2) => -1234.56 instead of -1234.57 (in comparison with postgis or python)

Is it the same problem?

#2 Updated by Loïc BARTOLETTI almost 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed

#3 Updated by Gabriel De Luca almost 6 years ago

Loïc BARTOLETTI wrote:

Is it the same problem?

Yes, also round( -100.00, 1) returns -99.9 instead of -100.0

Thanks for fix it.

Also available in: Atom PDF