From f3f29795da461905a5e9f0314dc0d7840bd75c3f Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Mon, 9 Feb 2015 21:38:02 +0100 Subject: add IEEE binary128 long double support to floatscan just defining the necessary constants: LD_B1B_MAX is 2^113 - 1 in base 10^9 KMAX is 2048 so the x array can hold up to 18432 decimal digits (the worst case is converting 2^-16495 = 5^16495 * 10^-16495 to binary, it requires the processing of int(log10(5)*16495)+1 = 11530 decimal digits after discarding the leading zeros, the conversion requires some headroom in x, but KMAX is more than enough for that) However this code is not optimal on archs with IEEE binary128 long double because the arithmetics is software emulated (on all such platforms as far as i know) which means big and slow strtod. --- src/internal/floatscan.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index f6e331d4..eef70df9 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -15,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) -- cgit v1.2.1