src\DoubleRound.java |
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author BeytullahC */ public class DoubleRound { public static void main(String[] args) { System.out.println(round(331.15d, 2)); } public static double round(double value, int places) { if (places < 0) { throw new IllegalArgumentException(); } long factor = (long) Math.pow(10, places); value = value * factor; long tmp = Math.round(value); return (double) tmp / factor; } }-->
Hiç yorum yok:
Yorum Gönder