Java Double Number Truncate trunc(double x, double y)

Here you can find the source of trunc(double x, double y)

Description

Truncate x down to the nearest y.

License

Open Source License

Declaration

public static double trunc(double x, double y) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w  w  w .j  ava2 s. c  o  m*/
     * Truncate x down to the nearest y.
     */
    public static double trunc(double x, double y) {
        return y * Math.floor((x + .00001) / y);
    }

    /**
     * Truncate x down to the nearest y.
     */
    public static double floor(double x, double y) {
        return y * Math.floor((x + .00001) / y);
    }
}

Related

  1. trunc(double value, double threshold)
  2. trunc(double value, int dp)
  3. trunc(double value, int len)
  4. trunc(double x)
  5. trunc(double x)
  6. trunc4(Double number)
  7. truncate(double d)
  8. truncate(double fullVal, int digits)
  9. truncate(double oldVal, double newMin, double newMax)