Python Forum
Rounding to the nearest eight
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rounding to the nearest eight
#1
Basically, I just need to round a number to the nearest eight and by my research the
round()
function cannot do that.
Reply
#2
Divide by 8, round(), multiply by 8.

>>> round(3.9 / 8) * 8
0
>>> round(4.1 / 8) * 8
8
Reply
#3
Thanks! That worked.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get numpy ceil and floor value for nearest two decimals klllmmm 4 1,198 Jun-07-2023, 07:35 AM
Last Post: paul18fr
  need help rounding joseph202020 7 1,257 Feb-21-2023, 08:13 PM
Last Post: joseph202020
  compare and find the nearest element ? mr_gentle_sausage 4 1,003 Jan-15-2023, 07:11 AM
Last Post: DPaul
  from numpy array to csv - rounding SchroedingersLion 6 2,063 Nov-14-2022, 09:09 PM
Last Post: deanhystad
  Random data generation sum to 1 by rounding juniorcoder 9 3,347 Oct-20-2021, 03:36 PM
Last Post: deanhystad
  Rounding issue kmll 1 1,379 Oct-08-2021, 10:35 AM
Last Post: Yoriz
  Not rounding to desired decimal places? pprod 2 2,504 Mar-05-2021, 11:11 AM
Last Post: pprod
  Decimal Rounding error project_science 4 2,696 Jan-06-2021, 03:14 PM
Last Post: project_science
  rounding and floats Than999 2 3,046 Oct-26-2020, 09:36 PM
Last Post: deanhystad
  rounding question DPaul 16 5,433 Apr-12-2020, 02:30 PM
Last Post: DPaul

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020