Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Rounding a decimal number

807597Apr 22 2005 — edited Apr 23 2005
Hi,
i'm still not clear about how to round a decimal number.....can anyone give me some specific example?
I'm told that, to round a decimal number, i have to first multiply the decimal number(double) with 100, then only i 'assign' it to an integer...but how do i do that? Any one tried this way before?
Lets say i have a code:
double total=0;
            double sum;
            .......................
             total = total + sum; 
After that i need to round the total (dollars) to nearest 5 cents. How to do that?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2005
Added on Apr 22 2005
3 comments
253 views