X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finternal%2Ffloatscan.c;h=278bf25025d64e1b6375e1b2a57ab5e2b3306246;hb=85dfab7eaf1624577ec6de8375fd771ef9b4672a;hp=f80db3839ea87ec2d0513f6c4f4bb1eff0aba05e;hpb=02eb568dedadb3d66c2751aba6bea559370ff32c;p=oweals%2Fmusl.git diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index f80db383..278bf250 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "shgetc.h" #include "floatscan.h" @@ -14,12 +15,20 @@ #define LD_B1B_MAX 9007199, 254740991 #define KMAX 128 -#else /* LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 */ +#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 #define LD_B1B_DIG 3 #define LD_B1B_MAX 18, 446744073, 709551615 #define KMAX 2048 +#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 + +#define LD_B1B_DIG 4 +#define LD_B1B_MAX 10384593, 717069655, 257060992, 658440191 +#define KMAX 2048 + +#else +#error Unsupported long double representation #endif #define MASK (KMAX-1) @@ -101,7 +110,10 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po gotdig=1; } else { dc++; - if (c!='0') x[KMAX-4] |= 1; + if (c!='0') { + lnz = (KMAX-4)*9; + x[KMAX-4] |= 1; + } } } if (!gotrad) lrp=dc; @@ -163,6 +175,9 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po return sign * (long double)x[0] * p10s[rp-10]; } + /* Drop trailing zeros */ + for (; !x[z-1]; z--); + /* Align radix point to B1B digit boundary */ if (rp % 9) { int rpm9 = rp>=0 ? rp%9 : rp%9+9; @@ -199,11 +214,11 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po } if (carry) { rp += 9; + a = (a-1 & MASK); if (a == z) { z = (z-1 & MASK); x[z-1 & MASK] |= x[z]; } - a = (a-1 & MASK); x[a] = carry; } } @@ -244,7 +259,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po /* Assemble desired bits into floating point variable */ for (y=i=0; i