Here you can find the source of trunc(float x)
public static float trunc(float x)
//package com.java2s; //License from project: Open Source License public class Main { public static float trunc(float x) { if (x < 0) { return (float) Math.ceil(x); } else {/*from w w w. j a v a 2 s. c om*/ return (float) Math.floor(x); } } }