cdm/src/main/java/ucar/unidata/geoloc/projection/proj4/MapMath.java
public static double niceNumber(double x, boolean round) {
		int expv;				/* exponent of x */
		double f;				/* fractional part of x */
		double nf;				/* nice, rounded fraction */

		expv = (int)Math.floor(Math.log(x) / Math.log(10));
		f = x/Math.pow(10., expv);		/* between 1 and 10 */
		if (round) {
			if (f < 1.5)
				nf = 1.;
			else if (f < 3.)
				nf = 2.;
			else if (f < 7.)
				nf = 5.;
			else
				nf = 10.;
		} else if (f <= 1.)
			nf = 1.;
		else if (f <= 2.)
			nf = 2.;
		else if (f <= 5.)
			nf = 5.;
		else
			nf = 10.;
		return nf*Math.pow(10., expv);
	}
public static double niceNumber(double x, boolean round) {
		int expv;				/* exponent of x */
		double f;				/* fractional part of x */
		double nf;				/* nice, rounded fraction */

		expv = (int)Math.floor(Math.log(x) / Math.log(10));
		f = x/Math.pow(10., expv);		/* between 1 and 10 */
		if (round) {
			if (f < 1.5)
				nf = 1.;
			else if (f < 3.)
				nf = 2.;
			else if (f < 7.)
				nf = 5.;
			else
				nf = 10.;
		} else if (f <= 1.)
			nf = 1.;
		else if (f <= 2.)
			nf = 2.;
		else if (f <= 5.)
			nf = 5.;
		else
			nf = 10.;
		return nf*Math.pow(10., expv);
	}
public static double niceNumber ( double x , boolean round ) { int expv ; /* exponent of x */ double f ; /* fractional part of x */ double nf ; /* nice, rounded fraction */ expv = ( int ) Math . floor ( Math . log ( x ) / Math . log ( 10 ) ) ; f = x / Math . pow ( 10. , expv ) ; /* between 1 and 10 */ if ( round ) { if ( f < 1.5 ) nf = 1. ; else if ( f < 3. ) nf = 2. ; else if ( f < 7. ) nf = 5. ; else nf = 10. ; } else if ( f <= 1. ) nf = 1. ; else if ( f <= 2. ) nf = 2. ; else if ( f <= 5. ) nf = 5. ; else nf = 10. ; return nf * Math . pow ( 10. , expv ) ; }
/*
Java translation of "Nice Numbers for Graph Labels"
by Paul Heckbert
from "Graphics Gems", Academic Press, 1990
/ * Java translation of Nice Numbers for Graph Labels by Paul Heckbert from Graphics Gems Academic Press 1990