ByteList buf = new ByteList();
// Under 1.9, use full-precision float formatting (JRUBY-4846).
// Double-precision can represent around 16 decimal digits;
// we use 20 to ensure full representation.
Sprintf.sprintf(buf, Locale.US, "%#.20g", this);
int e = buf.indexOf('e');
if (e == -1) e = buf.getRealSize();
ASCIIEncoding ascii = ASCIIEncoding.INSTANCE;
if (!ascii.isDigit(buf.get(e - 1))) {
buf.setRealSize(0);