}
func DecimalToFloatBits(neg bool, d *Decimal, trunc bool, flt *FloatInfo) (b uint64, overflow bool) {
+ var exp int;
+ var mant uint64;
+
// Zero is always a special case.
if d.nd == 0 {
- return 0, false
+ mant = 0;
+ exp = flt.bias;
+ goto out;
}
- var exp int;
- var mant uint64;
-
// Obvious overflow/underflow.
// These bounds are for 64-bit floats.
// Will have to change if we want to support 80-bit floats in the future.
f = f*10 + float64(d.d[i] - '0');
}
if neg {
- f = -f;
+ f *= -1; // BUG work around 6g f = -f.
}
return f;
}
f = f*10 + float32(d.d[i] - '0');
}
if neg {
- f = -f;
+ f *= -1; // BUG work around 6g f = -f.
}
return f;
}
Test{ "100000000000000016777215", "1.0000000000000001e+23", nil },
Test{ "100000000000000016777216", "1.0000000000000003e+23", nil },
Test{ "-1", "-1", nil },
- Test{ "-0", "0", nil },
+ Test{ "-0", "-0", nil },
Test{ "1e-20", "1e-20", nil },
Test{ "625e-3", "0.625", nil },