mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-27 23:34:18 +08:00
Calculate hex floating point with 128 bits instead of 64 bits.
Some checks are pending
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
Some checks are pending
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
This commit is contained in:
parent
83de532563
commit
cb39bc4cac
19
tccpp.c
19
tccpp.c
@ -2231,8 +2231,13 @@ static void parse_string(const char *s, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we use 64 bit numbers */
|
#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
|
||||||
|
/* we use 64 bit (52 needed) numbers */
|
||||||
#define BN_SIZE 2
|
#define BN_SIZE 2
|
||||||
|
#else
|
||||||
|
/* we use 128 bit (64/112 needed) numbers */
|
||||||
|
#define BN_SIZE 4
|
||||||
|
#endif
|
||||||
|
|
||||||
/* bn = (bn << shift) | or_val */
|
/* bn = (bn << shift) | or_val */
|
||||||
static void bn_lshift(unsigned int *bn, int shift, int or_val)
|
static void bn_lshift(unsigned int *bn, int shift, int or_val)
|
||||||
@ -2261,7 +2266,11 @@ static void parse_number(const char *p)
|
|||||||
int b, t, shift, frac_bits, s, exp_val, ch;
|
int b, t, shift, frac_bits, s, exp_val, ch;
|
||||||
char *q;
|
char *q;
|
||||||
unsigned int bn[BN_SIZE];
|
unsigned int bn[BN_SIZE];
|
||||||
|
#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
|
||||||
double d;
|
double d;
|
||||||
|
#else
|
||||||
|
long double d;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* number */
|
/* number */
|
||||||
q = token_buf;
|
q = token_buf;
|
||||||
@ -2374,8 +2383,16 @@ static void parse_number(const char *p)
|
|||||||
|
|
||||||
/* now we can generate the number */
|
/* now we can generate the number */
|
||||||
/* XXX: should patch directly float number */
|
/* XXX: should patch directly float number */
|
||||||
|
#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
|
||||||
d = (double)bn[1] * 4294967296.0 + (double)bn[0];
|
d = (double)bn[1] * 4294967296.0 + (double)bn[0];
|
||||||
d = ldexp(d, exp_val - frac_bits);
|
d = ldexp(d, exp_val - frac_bits);
|
||||||
|
#else
|
||||||
|
d = (long double)bn[3] * 79228162514264337593543950336.0L +
|
||||||
|
(long double)bn[2] * 18446744073709551616.0L +
|
||||||
|
(long double)bn[1] * 4294967296.0L +
|
||||||
|
(long double)bn[0];
|
||||||
|
d = ldexpl(d, exp_val - frac_bits);
|
||||||
|
#endif
|
||||||
t = toup(ch);
|
t = toup(ch);
|
||||||
if (t == 'F') {
|
if (t == 'F') {
|
||||||
ch = *p++;
|
ch = *p++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user