History

Calculate hex floating point with 128 bits instead of 64 bits.

herman ten brugge committed 1 year ago

Commit cb39bc41 parent 83de5321 file · +18 −1Browse files

Unified · Split

tccpp.c+18−1
@@ -2231,8 +2231,13 @@ static void parse_string(const char *s, int len) · 2230 unmodified lines
2231 }2231 }
2232}2232}
2233 2233
2234/* we use 64 bit numbers */2234#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
2235/* we use 64 bit (52 needed) numbers */
2235#define BN_SIZE 22236#define BN_SIZE 2
2237#else
2238/* we use 128 bit (64/112 needed) numbers */
2239#define BN_SIZE 4
2240#endif
2236 2241
2237/* bn = (bn << shift) | or_val */2242/* bn = (bn << shift) | or_val */
2238static void bn_lshift(unsigned int *bn, int shift, int or_val)2243static void bn_lshift(unsigned int *bn, int shift, int or_val)
@@ -2261,7 +2266,11 @@ static void parse_number(const char *p) · 22 unmodified lines
2261 int b, t, shift, frac_bits, s, exp_val, ch;2266 int b, t, shift, frac_bits, s, exp_val, ch;
2262 char *q;2267 char *q;
2263 unsigned int bn[BN_SIZE];2268 unsigned int bn[BN_SIZE];
2269#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
2264 double d;2270 double d;
2271#else
2272 long double d;
2273#endif
2265 2274
2266 /* number */2275 /* number */
2267 q = token_buf;2276 q = token_buf;
@@ -2374,8 +2383,16 @@ static void parse_number(const char *p) · 106 unmodified lines
2374 2383
2375 /* now we can generate the number */2384 /* now we can generate the number */
2376 /* XXX: should patch directly float number */2385 /* XXX: should patch directly float number */
2386#ifdef TCC_USING_DOUBLE_FOR_LDOUBLE
2377 d = (double)bn[1] * 4294967296.0 + (double)bn[0];2387 d = (double)bn[1] * 4294967296.0 + (double)bn[0];
2378 d = ldexp(d, exp_val - frac_bits);2388 d = ldexp(d, exp_val - frac_bits);
2389#else
2390 d = (long double)bn[3] * 79228162514264337593543950336.0L +
2391 (long double)bn[2] * 18446744073709551616.0L +
2392 (long double)bn[1] * 4294967296.0L +
2393 (long double)bn[0];
2394 d = ldexpl(d, exp_val - frac_bits);
2395#endif
2379 t = toup(ch);2396 t = toup(ch);
2380 if (t == 'F') {2397 if (t == 'F') {
2381 ch = *p++;2398 ch = *p++;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t