Here you can find the source of round(float value, float snap)
public static float round(float value, float snap)
//package com.java2s; //License from project: Apache License public class Main { public static float round(float value, float snap) { if (snap == 0.0f) return value; return ((int) (value / snap)) * snap; }//from w w w . j a v a 2 s . co m }