Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round Up Number To Nearest 5 or 0 1

Status
Not open for further replies.

axLW

Programmer
Feb 6, 2015
110
GB
Can somebody please tell me the best way to round up a number like so:

79 > 80
42 > 45
31 > 35
146 > 150

etc

My numeric value is held in a variable called MyVar.

Thanks
 
Try
Code:
x = ((x - 1) \ 5 + 1) * 5
 
Yes that works. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top