Here you can find the source of frac(float x)
public static float frac(float x)
//package com.java2s; //License from project: Open Source License public class Main { public static float frac(float x) { return x - trunc(x); }//from ww w. ja v a2 s . c o m public static float trunc(float x) { if (x < 0) { return (float) Math.ceil(x); } else { return (float) Math.floor(x); } } }