Box
Mechanical
- Mar 11, 2002
- 6
This may help someone. I recently developed a spreadsheet that calculated some pressure settings for a machine I was in charge of. The pressure gage read in 50 psi incriments, but my spreadsheet output was rounded to the nearest 1 psi. Excel will round to decimal places, not numbers, ie..1-10-100-etc..., or 0.1-0.01-0.001 etc. So I developed an equation that will round to the nearest set value, being any number, interger or otherwise. You could round to the nearest Pi if you wanted to. So here it is:
# = the number you want to round
RN = the number to round to
IP = take the interger part
Rounded Number = IP[(#/RN)+.5] * RN
Basically, take your number #, and divide it by what you want to round to, RN. Add .5 to it, and take the integer part. Then multiply by the RN number again.
Good luck to all, hope this helps someone.
Gary
# = the number you want to round
RN = the number to round to
IP = take the interger part
Rounded Number = IP[(#/RN)+.5] * RN
Basically, take your number #, and divide it by what you want to round to, RN. Add .5 to it, and take the integer part. Then multiply by the RN number again.
Good luck to all, hope this helps someone.
Gary