/*** * MUST represent all integer numbers (those with a zero-valued fractional part) * without a leading minus sign when the value is zero, and * without a decimal point, and * without an exponent * * MUST represent all non-integer numbers in exponential notation * including a nonzero single-digit significant integer part, and * including a nonempty significant fractional part, and * including no trailing zeroes in the significant fractional part (other than as part of a ".0" required to satisfy the preceding point), and * including a capital "E", and * including no plus sign in the exponent, and * including no insignificant leading zeroes in the exponent * @param bd * @throws IOException */ private void SerializeNumber(string value) { BigDecimal bd = new BigDecimal(value); try { //attempt converting to fixed number buffer.append(bd.toBigIntegerExact().toString()); } catch (java.lang.ArithmeticException) { NumberFormat formatter = new DecimalFormat("0.0E0"); formatter.setMinimumFractionDigits(1); formatter.setMaximumFractionDigits(bd.precision()); string val = formatter.format(bd).Replace("+", ""); buffer.append(val); } }