class MathUtils {

    public static double roundFraction( double value, int n )
    {
        if ( isEqual( value, 0.0 ) )
        {
            return 0.0;
        }

        final double d = Math.ceil( Math.log10( value < 0.0 ? -value : value ) );

        if ( d >= n )
        {
            return (double) Math.round( value );
        }

        return roundToSignificantDigits( value ,n );
    }

}