Java Double Number Round round(double amount)

Here you can find the source of round(double amount)

Description

round

License

Apache License

Declaration

public static double round(double amount) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double round(double amount) {
        double tmp1 = amount;
        long factor = (long) Math.pow(10, 2);
        tmp1 = tmp1 * factor;//from  www  .  j a va 2 s .c  o m
        long tmp = Math.round(Math.abs(tmp1));
        amount = ((amount < 0 && tmp != 0) ? -1 : 1) * ((double) tmp / factor);
        String[] strArr = String.valueOf(amount).split("\\.");
        //
        // amount = Double.parseDouble(strArr[0] + "."
        // + (strArr.length > 1 ? strArr[1].substring(0, 2) : "00"));
        return amount;
    }
}

Related

  1. Round(double a)
  2. round(double a, double precision)
  3. round(double a, int cutOfDigits)
  4. round(double a, int decimal)
  5. round(double a, int rounding_style)
  6. round(double amt, int digits)
  7. round(double d)
  8. round(double d)
  9. round(double d)