Advertisement
Guest User

Untitled

a guest
May 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. package me.kygran.euphoria.utils;
  2.  
  3. import java.math.BigDecimal;
  4. import java.math.RoundingMode;
  5.  
  6. public class MathUtils {
  7. public static double round(double value, int places) {
  8. if (places < 0) {
  9. throw new IllegalArgumentException();
  10. }
  11. BigDecimal bd = new BigDecimal(value);
  12. bd = bd.setScale(places, RoundingMode.HALF_UP);
  13. return bd.doubleValue();
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement