question: public String str ( ) { if ( Double . isNaN ( m_val ) ) { return "NaN" ; } else if ( Double . isInfinite ( m_val ) ) { if ( m_val > 0 ) return "Infinity" ; else return "-Infinity" ; } double num = m_val ; String s = Double . toString ( num ) ; int len = s . length ( ) ; if ( s . charAt ( len - 2 ) == '.' && s . charAt ( len - 1 ) == '0' ) { s = s . substring ( 0 , len - 2 ) ; if ( s . equals ( "-0" ) ) return "0" ; return s ; } int e = s . indexOf ( 'E' ) ; if ( e < 0 ) { if ( s . charAt ( len - 1 ) == '0' ) return s . substring ( 0 , len - 1 ) ; else return s ; } int exp = Integer . parseInt ( s . substring ( e + 1 ) ) ; String sign ; if ( s . charAt ( 0 ) == '-' ) { sign = "-" ; s = s . substring ( 1 ) ; -- e ; } else sign = "" ; int nDigits = e - 2 ; if ( exp >= nDigits ) return sign + s . substring ( 0 , 1 ) + s . substring ( 2 , e ) + zeros ( exp - nDigits ) ; while ( s . charAt ( e - 1 ) == '0' ) e -- ; if ( exp > 0 ) return sign + s . substring ( 0 , 1 ) + s . substring ( 2 , 2 + exp ) + "." + s . substring ( 2 + exp , e ) ; return sign + "0." + zeros ( - 1 - exp ) + s . substring ( 0 , 1 ) + s . substring ( 2 , e ) ; }
target:  Cast result object to a string.