Java Double Number Truncate truncate(double d)

Here you can find the source of truncate(double d)

Description

truncate

License

Open Source License

Declaration

public static double truncate(double d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Educational Online Test Delivery System Copyright (c) 2014 American
 * Institutes for Research/*  w w  w  . j av a  2s  .  c  o  m*/
 * 
 * Distributed under the AIR Open Source License, Version 1.0 See accompanying
 * file AIR-License-1_0.txt or at http://www.smarterapp.org/documents/
 * American_Institutes_for_Research_Open_Source_Software_License.pdf
 ******************************************************************************/

public class Main {
    public static double truncate(double d) {
        if (d < 0)
            return -1 * Math.floor(d * -1);
        else
            return Math.floor(d);
    }
}

Related

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