469,306 Members | 2,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Round up

How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan
Jul 19 '05 #1
4 7973
Ruslan wrote:
How can I round up a float number?


Math.Ceiling
Jul 19 '05 #2
add 0.5 and truncate?

Ruslan wrote:
How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan


Jul 19 '05 #3
Ruslan,
Have you tried System.Math.Ceiling? Which returns the smallest whole number
greater than or equal to the specified number.

Note for negative numbers it will return numbers closer to zero.

Ceiling(-3.6) will return -3.

The function System.Match.Floor will return the smallest whole number less
than or equal to the specified number.

Hope this helps
Jay

"Ruslan" <ru*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan

Jul 19 '05 #4
Thanks, Jay

It helped me.

Ruslan

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:#Q**************@TK2MSFTNGP12.phx.gbl...
Ruslan,
Have you tried System.Math.Ceiling? Which returns the smallest whole number greater than or equal to the specified number.

Note for negative numbers it will return numbers closer to zero.

Ceiling(-3.6) will return -3.

The function System.Match.Floor will return the smallest whole number less
than or equal to the specified number.

Hope this helps
Jay

"Ruslan" <ru*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I round up a float number?

For example:

If I have a number 3.6 I want to obtain 4 and

If I have a number 3.1 also to obtain 4

Thanks a lot.

Ruslan


Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Matias Silva | last post: by
17 posts views Thread by nomenklatura | last post: by
9 posts views Thread by Ronald W. Roberts | last post: by
4 posts views Thread by Fuzzydave | last post: by
10 posts views Thread by David Coleman | last post: by
7 posts views Thread by kkmigas | last post: by
3 posts views Thread by Krishna.K.1900 | last post: by
4 posts views Thread by =?Utf-8?B?UmVuZQ==?= | last post: by
9 posts views Thread by josh logan | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.