mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
hex float parsing: solve another case
this works now: 0x1.edcb34a235253948765432134674fp-1
This commit is contained in:
parent
af509c68b0
commit
d04a1456df
@ -365,6 +365,9 @@ static void end_float_token(Tokenize *t) {
|
||||
bigint_init_unsigned(&shift_bigint, -shift);
|
||||
BigInt shifted_significand;
|
||||
bigint_shr(&shifted_significand, &t->significand, &shift_bigint);
|
||||
if (t->exponent_in_bin_or_dec == -1) {
|
||||
bigint_incr(&shifted_significand);
|
||||
}
|
||||
bigint_write_twos_complement(&shifted_significand, (uint8_t*) f_bits.repr, 128, false);
|
||||
} else {
|
||||
uint64_t sig_bits[2] = {0, 0};
|
||||
|
||||
@ -310,8 +310,14 @@ test "quad hex float literal parsing accurate" {
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() void {
|
||||
var f1: f128 = 0x1.2eab345678439abcdefea56782346p+5;
|
||||
expect(@bitCast(u128, f1) == 0x40042eab345678439abcdefea5678234);
|
||||
{
|
||||
var f1: f128 = 0x1.2eab345678439abcdefea56782346p+5;
|
||||
expect(@bitCast(u128, f1) == 0x40042eab345678439abcdefea5678234);
|
||||
}
|
||||
{
|
||||
var f: f128 = 0x1.edcb34a235253948765432134674fp-1;
|
||||
expect(@bitCast(u128, f) == 0x3ffeedcb34a235253948765432134675);
|
||||
}
|
||||
const exp2ft = []f64{
|
||||
0x1.6a09e667f3bcdp-1,
|
||||
0x1.7a11473eb0187p-1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user