Rounding to the nearest eight - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Rounding to the nearest eight (/thread-28356.html) |
Rounding to the nearest eight - wallgraffiti - Jul-15-2020 Basically, I just need to round a number to the nearest eight and by my research the round()function cannot do that. RE: Rounding to the nearest eight - bowlofred - Jul-15-2020 Divide by 8, round(), multiply by 8. >>> round(3.9 / 8) * 8 0 >>> round(4.1 / 8) * 8 8 RE: Rounding to the nearest eight - wallgraffiti - Jul-15-2020 Thanks! That worked. |