Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Rounding

Subject: Rounding

From: Sam Grayson

Date: 7 Apr, 2009 23:44:01

Message: 1 of 3

Hey,

Can anyone help to round a decimal to the nearest even integer.

e.g. 69.1 would be rounded to 70 and 2.9 would be rounded to 2...

Thanks

Subject: Rounding

From: John D'Errico

Date: 7 Apr, 2009 23:49:01

Message: 2 of 3

"Sam Grayson" <samgrayson2@hotmail.com> wrote in message <grgog1$hot$1@fred.mathworks.com>...
> Hey,
>
> Can anyone help to round a decimal to the nearest even integer.
>
> e.g. 69.1 would be rounded to 70 and 2.9 would be rounded to 2...
>
> Thanks

Suppose you divided by 2?

What would round do then?

Multiply by 2 afterwards.

John

Subject: Rounding

From: Roger Stafford

Date: 7 Apr, 2009 23:50:17

Message: 3 of 3

"Sam Grayson" <samgrayson2@hotmail.com> wrote in message <grgog1$hot$1@fred.mathworks.com>...
> Can anyone help to round a decimal to the nearest even integer.
> e.g. 69.1 would be rounded to 70 and 2.9 would be rounded to 2...

 2*round(x/2)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us