Enable MICROPY_PY_BUILTINS_ROUND_INT; make round() work better when flag is disabled #1896
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1890.
Set
MICROPY_PY_BUILTINS_ROUND_INT
=1
for all builds, which implementsround(n, <negative ndigits>)
, so that, for instanceround(189, -1)
will round to the nearest 10.Also tweaks the implementation so that even if
MICROPY_PY_BUILTINS_ROUND_INT
=0
,round(<int>, <positive ndigits>)
will still work. Previously rounding an int with a specified ndigits would throwNotImplementedError
.Adds 151 bytes or so to a build.