Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

round to the nearest 0.5

def custom_round(x, base=0.5):
    return base * round(float(x)/base)

# you can replace the base parameter with the nearest rounding you need 
    
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nearest
ADD COMMENT
Topic
Name
5+6 =