Here you can find the source of roundIfClose(double val)
Parameter | Description |
---|---|
val | a parameter |
protected static double roundIfClose(double val)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww . j av a2 s . c om * Local function to round "sufficiently close" Number values to whole * numbers, to prevent unnecessary aliasing in drawing shapes. * * @param val * @return */ protected static double roundIfClose(double val) { double nVal = Math.round(val); if (Math.abs(val - nVal) < 0.001) { return nVal; } else { return val; } } }