Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qgib opened this issue Dec 21, 2018 · 3 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions

Comments

@qgib
Copy link
Contributor

qgib commented Dec 21, 2018

Author Name: Gabriel De Luca (@gabriel-de-luca)
Original Redmine Issue: 20861
Affected QGIS version: 3.5(master)
Redmine category:expressions
Assignee: Loïc BARTOLETTI


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.

@qgib
Copy link
Contributor Author

qgib commented Jan 29, 2019

Author Name: Loïc BARTOLETTI (@lbartoletti)


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?


  • operating_system was changed from Windows 10 to
  • version was changed from 3.4.2 to 3.5(master)
  • assigned_to_id was configured as Loïc BARTOLETTI
  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Jan 29, 2019

Author Name: Loïc BARTOLETTI (@lbartoletti)


Applied in changeset cfdc8c2.


  • done_ratio was changed from 0 to 100
  • status_id was changed from Feedback to Closed

@qgib qgib closed this as completed Jan 29, 2019
@qgib
Copy link
Contributor Author

qgib commented Jan 29, 2019

Author Name: Gabriel De Luca (@gabriel-de-luca)


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.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions
Projects
None yet
Development

No branches or pull requests

1 participant