static public String doubleToString(double d){
  if (Double.isInfinite(d) || Double.isNaN(d)) {
    return "null";
  }
  String s=Double.toString(d);
  if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) {
    while (s.endsWith("0")) {
      s=s.substring(0,s.length() - 1);
    }
    if (s.endsWith(".")) {
      s=s.substring(0,s.length() - 1);
    }
  }
  return s;
}

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