Java tutorial
//package com.java2s; public class Main { private static long fromSourceCoords(double value, int inSampleSize, long max) { long result = Math.round(value / inSampleSize); if (result <= 0) return 0; if (result >= max) return max; return result; } }