> how do i round decimal numbers?
>
> iv tried Math.round.rental but it wont work. i think im doing it wrong!!!
TRY
long roundedResult = Math.round(rental)
Show us the code.
Math.round(yourNumber) returns a long if yourNumber is a double - but
returns an int if yourNumber is a float.
If you're wanting to round to a certain number of places, there are several
approaches.
1. Look at the NumberFormat class in the API -
OR
2. to round to 2 digits - multiply by 100 - then round to an int, then
divide by 100.
cbroussard@liquiddatainc.com - 26 Nov 2005 23:56 GMT
I'd also look at
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html.
www.binaryfrost.com
>how do i round decimal numbers?
To round a float or double, use Math.round or add .5 and convert to
int.
To round a BigDecmial use BigDecmial.round

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.