Here you can find the source of truncate(double x)
static public int truncate(double x)
//package com.java2s; //License from project: Open Source License public class Main { static public int truncate(double x) { int res;//www .j a v a2 s. c o m if (x > 255) res = 255; else if (x < 0) res = 0; else res = (int) x; return res; } }