Want more features on Pastebin? Sign Up, it's FREE!

Function to truncate too much decimals

By: a guest on Jul 20th, 2013  |  syntax: Java  |  size: 0.16 KB  |  views: 110  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. static public double truncateDecimals(double n, int numberOfDecimals){
  2.        return Math.floor(n*Math.pow(10,numberOfDecimals))/Math.pow(10, numberOfDecimals);
  3. }
clone this paste RAW Paste Data