Here you can find the source of trunc(double x)
Parameter | Description |
---|---|
x | The double whose integer portion is to be found. |
Example: trunc( 30.12345D ) is 30.0D .
public static double trunc(double x)
//package com.java2s; /* Please see the license information in the header below. */ public class Main { /** Return the integer portion of a double as a double. */* w w w .jav a 2 s. c o m*/ * @param x The double whose integer portion is to be found. * * @return The integer portion of x. * * <p> * Example: trunc( 30.12345D ) is 30.0D . * </p> */ public static double trunc(double x) { long lx = (long) x; return (double) lx; } }