By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,746 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

rounding numbers up

P: n/a
i tryed searching on this on google but i didnt find anything like i
wanted, how do i round a number up, like 1.39 to 2?

Thanks paul
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"trs1800" <no**@coo.ca> wrote in message
news:I1**************@fe2.texas.rr.com...
i tryed searching on this on google but i didnt find anything like i
wanted, how do i round a number up, like 1.39 to 2?

Thanks paul


I'm not aware of any standard methods that will do this for you. All you
have to do though is add 0.5 and then use Math.round(). Alternately, add 1
and use Math.floor(), cutting out the middleman as Math.round() adds 0.5 and
calls Math.floor().
Jul 17 '05 #2

P: n/a
"Ryan Stewart" wrote
"trs1800" wrote:
i tryed searching on this on google but i didnt find anything like i
wanted, how do i round a number up, like 1.39 to 2?

Thanks paul
I'm not aware of any standard methods that will do this for you. All you
have to do though is add 0.5 and then use Math.round(). Alternately, add 1
and use Math.floor(), cutting out the middleman as Math.round() adds 0.5

and calls Math.floor().


Math class also contains:
static double ceil(double a)
Returns the smallest (closest to negative infinity) double value
that is not less than the argument and is equal to a mathematical integer.
Jul 17 '05 #3

P: n/a
"Tom N" <to*@nospam.au> wrote in message
news:mi*****************@news-server.bigpond.net.au...
"Ryan Stewart" wrote
"trs1800" wrote:
i tryed searching on this on google but i didnt find anything like i
wanted, how do i round a number up, like 1.39 to 2?

Thanks paul


I'm not aware of any standard methods that will do this for you. All you
have to do though is add 0.5 and then use Math.round(). Alternately, add 1 and use Math.floor(), cutting out the middleman as Math.round() adds 0.5

and
calls Math.floor().


Math class also contains:
static double ceil(double a)
Returns the smallest (closest to negative infinity) double value
that is not less than the argument and is equal to a mathematical integer.

Duh. I guess that is what he wants, huh?
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.