question: public static String doubleToString ( double d ) { if ( Double . isInfinite ( d ) || Double . isNaN ( d ) ) { return "null" ; } String string = Double . toString ( d ) ; if ( string . indexOf ( '.' ) > 0 && string . indexOf ( 'e' ) < 0 && string . indexOf ( 'E' ) < 0 ) { while ( string . endsWith ( "0" ) ) { string = string . substring ( 0 , string . length ( ) - 1 ) ; } if ( string . endsWith ( "." ) ) { string = string . substring ( 0 , string . length ( ) - 1 ) ; } } return string ; }
target:  Produce a string from a double. The string "null" will be returned if the number is not finite.