Skip to content

Instantly share code, notes, and snippets.

@nam20485
Last active August 1, 2018 15:42
Show Gist options
  • Save nam20485/b359b1b16c6d536e0b0cfe55286c6bbd to your computer and use it in GitHub Desktop.
Save nam20485/b359b1b16c6d536e0b0cfe55286c6bbd to your computer and use it in GitHub Desktop.
Round a number x, to the nearest multiple of m
increment = 0.002
decimal_places = -3
def round_to_nearest_multiple(value, increment, decimal_places):
rounded_value = round(x*increment, decimal_places)/increment
return rounded_value
v = 45.901
m = 0.002
d = -3
rounded_value = round(v, m, d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment