"trs1800" <nolo@coo.ca> wrote in message
news:I1b%b.1217 $as.93@fe2.texa s.rr.com...[color=blue]
> 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[/color]
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().
"Ryan Stewart" wrote[color=blue]
> "trs1800" wrote:[color=green]
> > 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[/color]
>
> 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[/color]
and[color=blue]
> calls Math.floor().[/color]
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.
"Tom N" <tom@nospam.a u> wrote in message
news:mid%b.7664 8$Wa.9744@news-server.bigpond. net.au...[color=blue]
> "Ryan Stewart" wrote[color=green]
> > "trs1800" wrote:[color=darkred]
> > > 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[/color]
> >
> > 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[/color][/color]
1[color=blue][color=green]
> > and use Math.floor(), cutting out the middleman as Math.round() adds 0.5[/color]
> and[color=green]
> > calls Math.floor().[/color]
>
> 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.
>
>[/color]
Duh. I guess that is what he wants, huh?
Comment