Correct floating-point literal allowed ranges

The exponent range for floating-point values is [-1022, 1023].

Fixes #399.
This commit is contained in:
Marc Tiehuis
2017-08-07 18:06:06 +12:00
parent d8227c79a2
commit 0705b711f8
4 changed files with 22 additions and 2 deletions

View File

@@ -333,7 +333,7 @@ static void end_float_token(Tokenize *t) {
} else {
int significand_magnitude_in_bin = __builtin_clzll(1) - __builtin_clzll(significand);
t->exponent_in_bin_or_dec += significand_magnitude_in_bin;
if (!(-1023 <= t->exponent_in_bin_or_dec && t->exponent_in_bin_or_dec < 1023)) {
if (!(-1022 <= t->exponent_in_bin_or_dec && t->exponent_in_bin_or_dec <= 1023)) {
t->cur_tok->data.float_lit.overflow = true;
return;
} else {