public static double truncate ( double value , int places ) { if ( places < 0 ) { throw new IllegalArgumentException ( ) ; } long factor = ( long ) java . lang . Math . pow ( 10 , places ) ; value = value * factor ; long tmp = ( long ) value ; return ( double ) tmp / factor ; }
Truncates a value