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 TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

rounding expression to nearest .25"

Status
Not open for further replies.

multicaduser

Industrial
Joined
Jan 29, 2013
Messages
261
Location
US
Must be brain fog, I know how to round an expression to any number of decimal places, how to use floor and ceiling, but am having a dickens of a time figuring out how to round to the nearest .25.

This formula always rounds up
ceiling(4*x)/4

This formula always rounds down
floor(4*x)/4

Examples of what I'm trying to accomplish
1.2 to 1.25
1.4 to 1.5
1.8 to 1.75
1.9 to 2

I know a long conditional statement to choose which formula will work but was wondering if some more elegant. Any ideas?


NX 1899 Windows 10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top