Last active
August 1, 2018 15:42
-
-
Save nam20485/b359b1b16c6d536e0b0cfe55286c6bbd to your computer and use it in GitHub Desktop.
Round a number x, to the nearest multiple of m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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