question: public static String formatDecimal ( double value , int precision , boolean bTruncateZeros , boolean bRound ) { if ( Double . isNaN ( value ) || Double . isInfinite ( value ) ) { return Constants . INFINITY_STRING ; } double tValue ; if ( bRound ) { tValue = value ; } else { if ( precision == 0 ) { tValue = ( long ) value ; } else { double shift = Math . pow ( 10 , precision ) ; tValue = ( ( long ) ( value * shift ) ) / shift ; } } int cache_index = ( precision << 2 ) + ( ( bTruncateZeros ? 1 : 0 ) << 1 ) + ( bRound ? 1 : 0 ) ; NumberFormat nf = null ; if ( cache_index < cached_number_formats . length ) { nf = cached_number_formats [ cache_index ] ; } if ( nf == null ) { nf = NumberFormat . getNumberInstance ( ) ; nf . setGroupingUsed ( false ) ; if ( ! bTruncateZeros ) { nf . setMinimumFractionDigits ( precision ) ; } if ( bRound ) { nf . setMaximumFractionDigits ( precision ) ; } if ( cache_index < cached_number_formats . length ) { cached_number_formats [ cache_index ] = nf ; } } return nf . format ( tValue ) ; }
target:  Format a real number