Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Round to nearest even number

Status
Not open for further replies.

vinerunner

Aerospace
Sep 4, 2013
11
Hi all!

I have the following question:

From an equation I get a number which is not round number but it's between 0-inf.
Let's say 81.321.

I would like to round this number to an even number.

So somehow like this: 81.321 -> 81 -> 82

The point is to get the "nearest" EVEN number.

My idea was that I'll use the floor function to make the rounded number but how can I make a number from that which is even for 100% sure?

Thanks!
 
Replies continue below

Recommended for you

Roughly, divide by two and do the floor, then multiply by two to get the value you want.
 
Thanks! During the night finally it came to my mind :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor