Round Off In N Decimal Places Using Java
Posted by informer on November 21, 2009 · Leave a Comment
This simple method will round off a value in N decimal places.
public static double round(double value, int decimalPlaces) {
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
...
Source: Tech Tips Tricks
Filed under BLOG · Tagged with
Disclaimer: PinoyBlogoSphere.com(PBS) claims no credit for any content(posts, articles, texts, images, videos) featured on this site unless otherwise noted. All contents are copyright to their owners/sources. PBS is in no way responsible for or has control of the content of any external web site links. Information on this site may contain errors or inaccuracies; we do not make warranty as to the correctness or reliability of the site’s content. If you own rights to any of the content, and do not wish them to appear on this site, please contact us via e-mail and they will be removed.
Random Posts
- November 24, 2009 -- Crib Recall Announcement on Tuesday
- October 13, 2009 -- Wearing Fake Boobs Is Classy
- November 25, 2009 -- Ayutthaya Market Photos
- December 12, 2009 -- Arroyo lifts martial law in Maguindanao
- December 19, 2009 -- Facial Masks for Dry Skin
- January 11, 2010 -- Highest Scoring NFL Playoff Game
- December 11, 2009 -- A Christmas Conversation in Oxen Time
- December 15, 2009 -- Bicycle Lights
- January 20, 2010 -- Lil Anzu and Okasan [Flickr]
- June 5, 2008 -- My Goal in 2 weeks….
- November 30, 2009 -- HINGGIL SA BAGAY-BAGAY NA MAGAGANAP SA HINAHARAP
- November 9, 2009 -- I’m Richard Domez.. kamag-anak ko si Richard Gomez
- December 22, 2009 -- The Future
- March 3, 2010 -- Stupid People
- May 26, 2010 -- Switch to Xenon Light
- October 10, 2009 -- Ang nawawalang wallet again. *bow*
- December 7, 2008 -- 8th Round Victory by Manny Pacquiao
- December 5, 2009 -- Cell Phones Probably Don’t Cause Brain Tumors
- December 18, 2009 -- ODESK Tips V1
- December 19, 2009 -- Amazon Associates and Blogger now Integrated