Here you can find the source of trunc(double x, double y)
public static double trunc(double x, double y)
//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); } }