Author
Need a function that converts a double into a whole int, rounding the decimal and ret
Zubi Pen
Greenhorn
Joined: Oct 24, 2007
Posts: 26
Hey peeps, I am new to java and I wanted to know how to make a little function that has a double value and returns a int value in form of a string . For example, So after running the function it returns the value: 12,346 Hence this does two things, places a comma afer the three digits and rounds the document in a whole number so 12345.56 becomes 12346 Can anyone help me how to do this. Thanks, Zub
Ragav Baskaran
Ranch Hand
Joined: Nov 04, 2007
Posts: 36
posted Sep 02, 2008 06:25:00
0
Try java.text.DecimalFormat class for formating. * Use format method Use java.lang.Math for rounding off numbers. * Math.round(<double> Hope this helps. Thanks Ragavendran [ September 02, 2008: Message edited by: Raga Vendran ] [ September 02, 2008: Message edited by: Raga Vendran ]
subject: Need a function that converts a double into a whole int, rounding the decimal and ret