basically i want to round up a number to the next 10 so 44 becomes 50 any number I've tried roundup = round(r8, -1) but this only rounds normally
Asked
Active
Viewed 46 times
0
-
`num=22; num = num/10; num = round(num);`? – Cyclonecode Oct 07 '16 at 08:22
-
It gives 2 instead of 30 – S. de Melo Oct 07 '16 at 08:26
-
oops forgot to multiply with 10 and since you want to round upwards you should use `ceil` instead: `num=22; num = num/10; num = ceil(num) * 10;` – Cyclonecode Oct 07 '16 at 08:38
-
`(num+9 if num >= 0 else num) // 10 * 10` – acw1668 Oct 07 '16 at 08:41
1 Answers
0
Try:
int(math.ceil(n / 10.)) * 10

S. de Melo
- 786
- 4
- 11
-
How does that not provide an answer to the question? Please read the question. – S. de Melo Oct 07 '16 at 11:23