Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: base/third_party/dmg_fp/dtoa.cc

Issue 21093: Allow clean compilation of dmg_fp under g++ -Wall -Werror (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/third_party/dmg_fp/README.chromium ('k') | base/third_party/dmg_fp/g_fmt.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /**************************************************************** 1 /****************************************************************
2 * 2 *
3 * The author of this software is David M. Gay. 3 * The author of this software is David M. Gay.
4 * 4 *
5 * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. 5 * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose without fee is hereby granted, provided that this entire notice 8 * purpose without fee is hereby granted, provided that this entire notice
9 * is included in all copies of any software which is or includes a copy 9 * is included in all copies of any software which is or includes a copy
10 * or modification of this software and in all copies of the supporting 10 * or modification of this software and in all copies of the supporting
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 (int k) 508 (int k)
509 #endif 509 #endif
510 { 510 {
511 int x; 511 int x;
512 Bigint *rv; 512 Bigint *rv;
513 #ifndef Omit_Private_Memory 513 #ifndef Omit_Private_Memory
514 unsigned int len; 514 unsigned int len;
515 #endif 515 #endif
516 516
517 ACQUIRE_DTOA_LOCK(0); 517 ACQUIRE_DTOA_LOCK(0);
518 » if (rv = freelist[k]) { 518 » if ((rv = freelist[k])) {
519 freelist[k] = rv->next; 519 freelist[k] = rv->next;
520 } 520 }
521 else { 521 else {
522 x = 1 << k; 522 x = 1 << k;
523 #ifdef Omit_Private_Memory 523 #ifdef Omit_Private_Memory
524 rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); 524 rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
525 #else 525 #else
526 len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1 ) 526 len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1 )
527 /sizeof(double); 527 /sizeof(double);
528 if (pmem_next - private_mem + len <= PRIVATE_mem) { 528 if (pmem_next - private_mem + len <= PRIVATE_mem) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 c = Balloc(k); 787 c = Balloc(k);
788 for(x = c->x, xa = x + wc; x < xa; x++) 788 for(x = c->x, xa = x + wc; x < xa; x++)
789 *x = 0; 789 *x = 0;
790 xa = a->x; 790 xa = a->x;
791 xae = xa + wa; 791 xae = xa + wa;
792 xb = b->x; 792 xb = b->x;
793 xbe = xb + wb; 793 xbe = xb + wb;
794 xc0 = c->x; 794 xc0 = c->x;
795 #ifdef ULLong 795 #ifdef ULLong
796 for(; xb < xbe; xc0++) { 796 for(; xb < xbe; xc0++) {
797 » » if (y = *xb++) { 797 » » if ((y = *xb++)) {
798 x = xa; 798 x = xa;
799 xc = xc0; 799 xc = xc0;
800 carry = 0; 800 carry = 0;
801 do { 801 do {
802 z = *x++ * (ULLong)y + *xc + carry; 802 z = *x++ * (ULLong)y + *xc + carry;
803 carry = z >> 32; 803 carry = z >> 32;
804 *xc++ = z & FFFFFFFF; 804 *xc++ = z & FFFFFFFF;
805 } 805 }
806 while(x < xae); 806 while(x < xae);
807 *xc = carry; 807 *xc = carry;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 #ifdef KR_headers 869 #ifdef KR_headers
870 (b, k) Bigint *b; int k; 870 (b, k) Bigint *b; int k;
871 #else 871 #else
872 (Bigint *b, int k) 872 (Bigint *b, int k)
873 #endif 873 #endif
874 { 874 {
875 Bigint *b1, *p5, *p51; 875 Bigint *b1, *p5, *p51;
876 int i; 876 int i;
877 static int p05[3] = { 5, 25, 125 }; 877 static int p05[3] = { 5, 25, 125 };
878 878
879 » if (i = k & 3) 879 » if ((i = k & 3))
880 b = multadd(b, p05[i-1], 0); 880 b = multadd(b, p05[i-1], 0);
881 881
882 if (!(k >>= 2)) 882 if (!(k >>= 2))
883 return b; 883 return b;
884 if (!(p5 = p5s)) { 884 if (!(p5 = p5s)) {
885 /* first time */ 885 /* first time */
886 #ifdef MULTIPLE_THREADS 886 #ifdef MULTIPLE_THREADS
887 ACQUIRE_DTOA_LOCK(1); 887 ACQUIRE_DTOA_LOCK(1);
888 if (!(p5 = p5s)) { 888 if (!(p5 = p5s)) {
889 p5 = p5s = i2b(625); 889 p5 = p5s = i2b(625);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 xe = x + b->wds; 950 xe = x + b->wds;
951 #ifdef Pack_32 951 #ifdef Pack_32
952 if (k &= 0x1f) { 952 if (k &= 0x1f) {
953 k1 = 32 - k; 953 k1 = 32 - k;
954 z = 0; 954 z = 0;
955 do { 955 do {
956 *x1++ = *x << k | z; 956 *x1++ = *x << k | z;
957 z = *x++ >> k1; 957 z = *x++ >> k1;
958 } 958 }
959 while(x < xe); 959 while(x < xe);
960 » » if (*x1 = z) 960 » » if ((*x1 = z))
961 ++n1; 961 ++n1;
962 } 962 }
963 #else 963 #else
964 if (k &= 0xf) { 964 if (k &= 0xf) {
965 k1 = 16 - k; 965 k1 = 16 - k;
966 z = 0; 966 z = 0;
967 do { 967 do {
968 *x1++ = *x << k & 0xffff | z; 968 *x1++ = *x << k & 0xffff | z;
969 z = *x++ >> k1; 969 z = *x++ >> k1;
970 } 970 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 x = b->x; 1252 x = b->x;
1253 1253
1254 z = d0 & Frac_mask; 1254 z = d0 & Frac_mask;
1255 d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ 1255 d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
1256 #ifdef Sudden_Underflow 1256 #ifdef Sudden_Underflow
1257 de = (int)(d0 >> Exp_shift); 1257 de = (int)(d0 >> Exp_shift);
1258 #ifndef IBM 1258 #ifndef IBM
1259 z |= Exp_msk11; 1259 z |= Exp_msk11;
1260 #endif 1260 #endif
1261 #else 1261 #else
1262 » if (de = (int)(d0 >> Exp_shift)) 1262 » if ((de = (int)(d0 >> Exp_shift)))
1263 z |= Exp_msk1; 1263 z |= Exp_msk1;
1264 #endif 1264 #endif
1265 #ifdef Pack_32 1265 #ifdef Pack_32
1266 » if (y = d1) { 1266 » if ((y = d1)) {
1267 » » if (k = lo0bits(&y)) { 1267 » » if ((k = lo0bits(&y))) {
1268 x[0] = y | z << 32 - k; 1268 x[0] = y | z << 32 - k;
1269 z >>= k; 1269 z >>= k;
1270 } 1270 }
1271 else 1271 else
1272 x[0] = y; 1272 x[0] = y;
1273 #ifndef Sudden_Underflow 1273 #ifndef Sudden_Underflow
1274 i = 1274 i =
1275 #endif 1275 #endif
1276 b->wds = (x[1] = z) ? 2 : 1; 1276 b->wds = (x[1] = z) ? 2 : 1;
1277 } 1277 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 1445
1446 #ifndef NAN_WORD1 1446 #ifndef NAN_WORD1
1447 #define NAN_WORD1 0 1447 #define NAN_WORD1 0
1448 #endif 1448 #endif
1449 1449
1450 static int 1450 static int
1451 match 1451 match
1452 #ifdef KR_headers 1452 #ifdef KR_headers
1453 (sp, t) char **sp, *t; 1453 (sp, t) char **sp, *t;
1454 #else 1454 #else
1455 » (CONST char **sp, char *t) 1455 » (CONST char **sp, CONST char *t)
1456 #endif 1456 #endif
1457 { 1457 {
1458 int c, d; 1458 int c, d;
1459 CONST char *s = *sp; 1459 CONST char *s = *sp;
1460 1460
1461 » while(d = *t++) { 1461 » while((d = *t++)) {
1462 if ((c = *++s) >= 'A' && c <= 'Z') 1462 if ((c = *++s) >= 'A' && c <= 'Z')
1463 c += 'a' - 'A'; 1463 c += 'a' - 'A';
1464 if (c != d) 1464 if (c != d)
1465 return 0; 1465 return 0;
1466 } 1466 }
1467 *sp = s + 1; 1467 *sp = s + 1;
1468 return 1; 1468 return 1;
1469 } 1469 }
1470 1470
1471 #ifndef No_Hex_NaN 1471 #ifndef No_Hex_NaN
(...skipping 11 matching lines...) Expand all
1483 1483
1484 x[0] = x[1] = 0; 1484 x[0] = x[1] = 0;
1485 havedig = xshift = 0; 1485 havedig = xshift = 0;
1486 udx0 = 1; 1486 udx0 = 1;
1487 s = *sp; 1487 s = *sp;
1488 /* allow optional initial 0x or 0X */ 1488 /* allow optional initial 0x or 0X */
1489 while((c = *(CONST unsigned char*)(s+1)) && c <= ' ') 1489 while((c = *(CONST unsigned char*)(s+1)) && c <= ' ')
1490 ++s; 1490 ++s;
1491 if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) 1491 if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X'))
1492 s += 2; 1492 s += 2;
1493 » while(c = *(CONST unsigned char*)++s) { 1493 » while((c = *(CONST unsigned char*)++s)) {
1494 if (c >= '0' && c <= '9') 1494 if (c >= '0' && c <= '9')
1495 c -= '0'; 1495 c -= '0';
1496 else if (c >= 'a' && c <= 'f') 1496 else if (c >= 'a' && c <= 'f')
1497 c += 10 - 'a'; 1497 c += 10 - 'a';
1498 else if (c >= 'A' && c <= 'F') 1498 else if (c >= 'A' && c <= 'F')
1499 c += 10 - 'A'; 1499 c += 10 - 'A';
1500 else if (c <= ' ') { 1500 else if (c <= ' ') {
1501 if (udx0 && havedig) { 1501 if (udx0 && havedig) {
1502 udx0 = 0; 1502 udx0 = 0;
1503 xshift = 1; 1503 xshift = 1;
1504 } 1504 }
1505 continue; 1505 continue;
1506 } 1506 }
1507 #ifdef GDTOA_NON_PEDANTIC_NANCHECK 1507 #ifdef GDTOA_NON_PEDANTIC_NANCHECK
1508 else if (/*(*/ c == ')' && havedig) { 1508 else if (/*(*/ c == ')' && havedig) {
1509 *sp = s + 1; 1509 *sp = s + 1;
1510 break; 1510 break;
1511 } 1511 }
1512 else 1512 else
1513 return; /* invalid form: don't change *sp */ 1513 return; /* invalid form: don't change *sp */
1514 #else 1514 #else
1515 else { 1515 else {
1516 do { 1516 do {
1517 if (/*(*/ c == ')') { 1517 if (/*(*/ c == ')') {
1518 *sp = s + 1; 1518 *sp = s + 1;
1519 break; 1519 break;
1520 } 1520 }
1521 » » » » } while(c = *++s); 1521 » » » » } while((c = *++s));
1522 break; 1522 break;
1523 } 1523 }
1524 #endif 1524 #endif
1525 havedig = 1; 1525 havedig = 1;
1526 if (xshift) { 1526 if (xshift) {
1527 xshift = 0; 1527 xshift = 0;
1528 x[0] = x[1]; 1528 x[0] = x[1];
1529 x[1] = 0; 1529 x[1] = 0;
1530 } 1530 }
1531 if (udx0) 1531 if (udx0)
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 else 1845 else
1846 if (Rounding != 2) 1846 if (Rounding != 2)
1847 Rounding = 0; 1847 Rounding = 0;
1848 } 1848 }
1849 #endif 1849 #endif
1850 #endif /*IEEE_Arith*/ 1850 #endif /*IEEE_Arith*/
1851 1851
1852 /* Get starting approximation = rv * 10**e1 */ 1852 /* Get starting approximation = rv * 10**e1 */
1853 1853
1854 if (e1 > 0) { 1854 if (e1 > 0) {
1855 » » if (i = e1 & 15) 1855 » » if ((i = e1 & 15))
1856 dval(rv) *= tens[i]; 1856 dval(rv) *= tens[i];
1857 if (e1 &= ~15) { 1857 if (e1 &= ~15) {
1858 if (e1 > DBL_MAX_10_EXP) { 1858 if (e1 > DBL_MAX_10_EXP) {
1859 ovfl: 1859 ovfl:
1860 #ifndef NO_ERRNO 1860 #ifndef NO_ERRNO
1861 errno = ERANGE; 1861 errno = ERANGE;
1862 #endif 1862 #endif
1863 /* Can't trust HUGE_VAL */ 1863 /* Can't trust HUGE_VAL */
1864 #ifdef IEEE_Arith 1864 #ifdef IEEE_Arith
1865 #ifdef Honor_FLT_ROUNDS 1865 #ifdef Honor_FLT_ROUNDS
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 /* (Can't trust DBL_MAX) */ 1905 /* (Can't trust DBL_MAX) */
1906 word0(rv) = Big0; 1906 word0(rv) = Big0;
1907 word1(rv) = Big1; 1907 word1(rv) = Big1;
1908 } 1908 }
1909 else 1909 else
1910 word0(rv) += P*Exp_msk1; 1910 word0(rv) += P*Exp_msk1;
1911 } 1911 }
1912 } 1912 }
1913 else if (e1 < 0) { 1913 else if (e1 < 0) {
1914 e1 = -e1; 1914 e1 = -e1;
1915 » » if (i = e1 & 15) 1915 » » if ((i = e1 & 15))
1916 dval(rv) /= tens[i]; 1916 dval(rv) /= tens[i];
1917 if (e1 >>= 4) { 1917 if (e1 >>= 4) {
1918 if (e1 >= 1 << n_bigtens) 1918 if (e1 >= 1 << n_bigtens)
1919 goto undfl; 1919 goto undfl;
1920 #ifdef Avoid_Underflow 1920 #ifdef Avoid_Underflow
1921 if (e1 & Scale_Bit) 1921 if (e1 & Scale_Bit)
1922 scale = 2*P; 1922 scale = 2*P;
1923 for(j = 0; e1 > 0; j++, e1 >>= 1) 1923 for(j = 0; e1 > 0; j++, e1 >>= 1)
1924 if (e1 & 1) 1924 if (e1 & 1)
1925 dval(rv) *= tinytens[j]; 1925 dval(rv) *= tinytens[j];
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 #ifdef KR_headers 2573 #ifdef KR_headers
2574 rv_alloc(i) int i; 2574 rv_alloc(i) int i;
2575 #else 2575 #else
2576 rv_alloc(int i) 2576 rv_alloc(int i)
2577 #endif 2577 #endif
2578 { 2578 {
2579 int j, k, *r; 2579 int j, k, *r;
2580 2580
2581 j = sizeof(ULong); 2581 j = sizeof(ULong);
2582 for(k = 0; 2582 for(k = 0;
2583 » » sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; 2583 » » sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (size_t)i;
2584 j <<= 1) 2584 j <<= 1)
2585 k++; 2585 k++;
2586 r = (int*)Balloc(k); 2586 r = (int*)Balloc(k);
2587 *r = k; 2587 *r = k;
2588 return 2588 return
2589 #ifndef MULTIPLE_THREADS 2589 #ifndef MULTIPLE_THREADS
2590 dtoa_result = 2590 dtoa_result =
2591 #endif 2591 #endif
2592 (char *)(r+1); 2592 (char *)(r+1);
2593 } 2593 }
2594 2594
2595 static char * 2595 static char *
2596 #ifdef KR_headers 2596 #ifdef KR_headers
2597 nrv_alloc(s, rve, n) char *s, **rve; int n; 2597 nrv_alloc(s, rve, n) char *s, **rve; int n;
2598 #else 2598 #else
2599 nrv_alloc(char *s, char **rve, int n) 2599 nrv_alloc(CONST char *s, char **rve, int n)
2600 #endif 2600 #endif
2601 { 2601 {
2602 char *rv, *t; 2602 char *rv, *t;
2603 2603
2604 t = rv = rv_alloc(n); 2604 t = rv = rv_alloc(n);
2605 » while(*t = *s++) t++; 2605 » while((*t = *s++)) t++;
2606 if (rve) 2606 if (rve)
2607 *rve = t; 2607 *rve = t;
2608 return rv; 2608 return rv;
2609 } 2609 }
2610 2610
2611 /* freedtoa(s) must be used to free values s returned by dtoa 2611 /* freedtoa(s) must be used to free values s returned by dtoa
2612 * when MULTIPLE_THREADS is #defined. It should be used in all cases, 2612 * when MULTIPLE_THREADS is #defined. It should be used in all cases,
2613 * but for consistency with earlier versions of dtoa, it is optional 2613 * but for consistency with earlier versions of dtoa, it is optional
2614 * when MULTIPLE_THREADS is not defined. 2614 * when MULTIPLE_THREADS is not defined.
2615 */ 2615 */
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 as modes 2 and 3 when FLT_ROUNDS != 1. 2700 as modes 2 and 3 when FLT_ROUNDS != 1.
2701 6-9 ==> Debugging modes similar to mode - 4: don't try 2701 6-9 ==> Debugging modes similar to mode - 4: don't try
2702 fast floating-point estimate (if applicable). 2702 fast floating-point estimate (if applicable).
2703 2703
2704 Values of mode other than 0-9 are treated as mode 0. 2704 Values of mode other than 0-9 are treated as mode 0.
2705 2705
2706 Sufficient space is allocated to the return value 2706 Sufficient space is allocated to the return value
2707 to hold the suppressed trailing zeros. 2707 to hold the suppressed trailing zeros.
2708 */ 2708 */
2709 2709
2710 » int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, 2710 » int bbits, b2, b5, be, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0,
2711 j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, 2711 j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
2712 spec_case, try_quick; 2712 spec_case, try_quick;
2713 Long L; 2713 Long L;
2714 #ifndef Sudden_Underflow 2714 #ifndef Sudden_Underflow
2715 int denorm; 2715 int denorm;
2716 ULong x; 2716 ULong x;
2717 #endif 2717 #endif
2718 Bigint *b, *b1, *delta, *mlo, *mhi, *S; 2718 Bigint *b, *b1, *delta, *mlo, *mhi, *S;
2719 double d2, ds, eps; 2719 double d2, ds, eps;
2720 char *s, *s0; 2720 char *s, *s0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 else 2785 else
2786 if (Rounding != 2) 2786 if (Rounding != 2)
2787 Rounding = 0; 2787 Rounding = 0;
2788 } 2788 }
2789 #endif 2789 #endif
2790 2790
2791 b = d2b(dval(d), &be, &bbits); 2791 b = d2b(dval(d), &be, &bbits);
2792 #ifdef Sudden_Underflow 2792 #ifdef Sudden_Underflow
2793 i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); 2793 i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
2794 #else 2794 #else
2795 » if (i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) { 2795 » if ((i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) {
2796 #endif 2796 #endif
2797 dval(d2) = dval(d); 2797 dval(d2) = dval(d);
2798 word0(d2) &= Frac_mask1; 2798 word0(d2) &= Frac_mask1;
2799 word0(d2) |= Exp_11; 2799 word0(d2) |= Exp_11;
2800 #ifdef IBM 2800 #ifdef IBM
2801 if (j = 11 - hi0bits(word0(d2) & Frac_mask)) 2801 if (j = 11 - hi0bits(word0(d2) & Frac_mask))
2802 dval(d2) /= 1 << j; 2802 dval(d2) /= 1 << j;
2803 #endif 2803 #endif
2804 2804
2805 /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 2805 /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2939 dval(d) /= bigtens[n_bigtens-1]; 2939 dval(d) /= bigtens[n_bigtens-1];
2940 ieps++; 2940 ieps++;
2941 } 2941 }
2942 for(; j; j >>= 1, i++) 2942 for(; j; j >>= 1, i++)
2943 if (j & 1) { 2943 if (j & 1) {
2944 ieps++; 2944 ieps++;
2945 ds *= bigtens[i]; 2945 ds *= bigtens[i];
2946 } 2946 }
2947 dval(d) /= ds; 2947 dval(d) /= ds;
2948 } 2948 }
2949 » » else if (j1 = -k) { 2949 » » else if ((j1 = -k)) {
2950 dval(d) *= tens[j1 & 0xf]; 2950 dval(d) *= tens[j1 & 0xf];
2951 for(j = j1 >> 4; j; j >>= 1, i++) 2951 for(j = j1 >> 4; j; j >>= 1, i++)
2952 if (j & 1) { 2952 if (j & 1) {
2953 ieps++; 2953 ieps++;
2954 dval(d) *= bigtens[i]; 2954 dval(d) *= bigtens[i];
2955 } 2955 }
2956 } 2956 }
2957 if (k_check && dval(d) < 1. && ilim > 0) { 2957 if (k_check && dval(d) < 1. && ilim > 0) {
2958 if (ilim1 <= 0) 2958 if (ilim1 <= 0)
2959 goto fast_failed; 2959 goto fast_failed;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 s2 -= i; 3100 s2 -= i;
3101 } 3101 }
3102 if (b5 > 0) { 3102 if (b5 > 0) {
3103 if (leftright) { 3103 if (leftright) {
3104 if (m5 > 0) { 3104 if (m5 > 0) {
3105 mhi = pow5mult(mhi, m5); 3105 mhi = pow5mult(mhi, m5);
3106 b1 = mult(mhi, b); 3106 b1 = mult(mhi, b);
3107 Bfree(b); 3107 Bfree(b);
3108 b = b1; 3108 b = b1;
3109 } 3109 }
3110 » » » if (j = b5 - m5) 3110 » » » if ((j = b5 - m5))
3111 b = pow5mult(b, j); 3111 b = pow5mult(b, j);
3112 } 3112 }
3113 else 3113 else
3114 b = pow5mult(b, b5); 3114 b = pow5mult(b, b5);
3115 } 3115 }
3116 S = i2b(1); 3116 S = i2b(1);
3117 if (s5 > 0) 3117 if (s5 > 0)
3118 S = pow5mult(S, s5); 3118 S = pow5mult(S, s5);
3119 3119
3120 /* Check for special case that d is a normalized power of 2. */ 3120 /* Check for special case that d is a normalized power of 2. */
(...skipping 17 matching lines...) Expand all
3138 } 3138 }
3139 3139
3140 /* Arrange for convenient computation of quotients: 3140 /* Arrange for convenient computation of quotients:
3141 * shift left if necessary so divisor has 4 leading 0 bits. 3141 * shift left if necessary so divisor has 4 leading 0 bits.
3142 * 3142 *
3143 * Perhaps we should just compute leading 28 bits of S once 3143 * Perhaps we should just compute leading 28 bits of S once
3144 * and for all and pass them and a shift to quorem, so it 3144 * and for all and pass them and a shift to quorem, so it
3145 * can do shifts and ors to compute the numerator for q. 3145 * can do shifts and ors to compute the numerator for q.
3146 */ 3146 */
3147 #ifdef Pack_32 3147 #ifdef Pack_32
3148 » if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) 3148 » if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f))
3149 i = 32 - i; 3149 i = 32 - i;
3150 #else 3150 #else
3151 if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) 3151 if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf)
3152 i = 16 - i; 3152 i = 16 - i;
3153 #endif 3153 #endif
3154 if (i > 4) { 3154 if (i > 4) {
3155 i -= 4; 3155 i -= 4;
3156 b2 += i; 3156 b2 += i;
3157 m2 += i; 3157 m2 += i;
3158 s2 += i; 3158 s2 += i;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 roundoff: 3315 roundoff:
3316 while(*--s == '9') 3316 while(*--s == '9')
3317 if (s == s0) { 3317 if (s == s0) {
3318 k++; 3318 k++;
3319 *s++ = '1'; 3319 *s++ = '1';
3320 goto ret; 3320 goto ret;
3321 } 3321 }
3322 ++*s++; 3322 ++*s++;
3323 } 3323 }
3324 else { 3324 else {
3325 #ifdef Honor_FLT_ROUNDS
3325 trimzeros: 3326 trimzeros:
3327 #endif
3326 while(*--s == '0'); 3328 while(*--s == '0');
3327 s++; 3329 s++;
3328 } 3330 }
3329 ret: 3331 ret:
3330 Bfree(S); 3332 Bfree(S);
3331 if (mhi) { 3333 if (mhi) {
3332 if (mlo && mlo != mhi) 3334 if (mlo && mlo != mhi)
3333 Bfree(mlo); 3335 Bfree(mlo);
3334 Bfree(mhi); 3336 Bfree(mhi);
3335 } 3337 }
(...skipping 11 matching lines...) Expand all
3347 #endif 3349 #endif
3348 Bfree(b); 3350 Bfree(b);
3349 *s = 0; 3351 *s = 0;
3350 *decpt = k + 1; 3352 *decpt = k + 1;
3351 if (rve) 3353 if (rve)
3352 *rve = s; 3354 *rve = s;
3353 return s0; 3355 return s0;
3354 } 3356 }
3355 3357
3356 } // namespace dmg_fp 3358 } // namespace dmg_fp
OLDNEW
« no previous file with comments | « base/third_party/dmg_fp/README.chromium ('k') | base/third_party/dmg_fp/g_fmt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698