← index #4792Issue #3023
Off-topic · high · value 1.495
QUERY · ISSUE

MICROPY_PY_BUILTINS_ROUND_INT==0 breaks round(<int>, <n>)

openby dhalbertopened 2019-05-16updated 2019-08-20

Before https://github.com/micropython/micropython/commit/b318ebf1015ced6354f8bbaf035308214b3f5c5d, which was a rework of #3557, round(<int>, <n>) worked. Now, if MICROPY_PY_BUILTINS_ROUND_INT is set to 0, round(2, 2) or similar throws NotImplementedError. round(2) still works.

@dpgeorge Was it your intention to disable rounding of integers in this way completely, instead of just not handling negative values for the second arg if it was an int?

A user discovered this after ending up with an integer zero while doing some floating arithmetic.

CANDIDATE · ISSUE

Problem with round on esp8266

closedby slzatzopened 2017-04-15updated 2017-05-01

MicroPython v1.8.7-623-g209eaec-dirty on 2017-04-15; ESP module with ESP8266

I haven't figured out the pattern (since some results are correct) but there appears to be a problem with round.

round(0.55, 1)
0.5
round(0.56, 1)
0.5999999

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied