mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-27 13:10:29 +00:00
423c2b9d08
TS 18661-1 defines fromfp functions (fromfp, fromfpx, ufromfp, ufromfpx, and float and long double variants) to convert from floating-point to an integer type with any signedness and any given width up to that of intmax_t, in any of the five IEEE rounding modes (the usual four for binary floating point, plus rounding to nearest with ties rounding away from zero), with control of whether in-range non-integer values should result in the "inexact" exception being raised. This patch implements these functions for glibc. These implementations are (apart from raising exceptions) pure integer implementations; it's entirely possible optimized versions could be devised for some architectures. A common math/fromfp.h header provides various common helper code that can readily be shared between the implementations for different types. For each type, the bulk of the implementation is also shared between the four functions, with wrappers that define UNSIGNED and INEXACT macros appropriately before including the main implementation. As the functions return intmax_t and uintmax_t without math.h being allowed to expose those typedef names, they are declared using __intmax_t and __uintmax_t as obtained from <bits/types.h>. The FP_INT_* rounding direction macros are defined as ascending integers in the order the names are listed in the TS; I see no significant value in allowing architectures to vary the values of them. The libm-test machinery is duly adapted to handle unsigned int arguments, and intmax_t and uintmax_t results. Because each test input is generally tested for four functions, five rounding modes and several different widths, the libm-test.inc additions are very large. Thus, the diffs in the body of this message exclude the libm-test.inc changes, with the full patch being attached gzipped. The bulk of the new tests were generated (expanded from a test input plus rounding results and information about where it lies in the relevant interval between integers, to libm-test tests for all relevant combinations of function, rounding direction and width) by a script that's included in the patch as math/gen-fromfp-tests.py (input data math/gen-fromfp-tests-inputs); as an ad hoc script that's not really expected to be rerun, it's not very polished, but it's at least plausibly useful for adding any further tests for these functions in future. I may split the libm-test tests up by function in future (so both libm-test.inc and auto-libm-test-out are split into separate files, and the tests for each function are also built and run separately), but not for 2.25. For no obvious reason, adding tgmath tests for the new functions resulted in -Wuninitialized errors from test-tgmath.c about the variable i being used uninitialized. Those errors were correct - the variable is read by the frexp version in test-tgmath.c (where real frexp would write through that pointer instead of reading it) - but I don't know why this patch would result in the pre-existing issue being newly detected. The patch initializes the variable to avoid those errors. With these changes, glibc 2.25 should have all the library features from TS 18661-1 other than the functions that round result to narrower type (and constant rounding directions, but I'm considering those mainly a compiler feature not a library one). Tested for x86_64, x86, mips64 and powerpc. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): New declaration. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise. * math/tgmath.h (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): New macro. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise. * math/math.h: Include <bits/types.h>. [__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_INT_UPWARD): New enum constant and macro. (FP_INT_DOWNWARD): Likewise. (FP_INT_TOWARDZERO): Likewise. (FP_INT_TONEARESTFROMZERO): Likewise. (FP_INT_TONEAREST): Likewise. * math/Versions (fromfp): New libm symbol at version GLIBC_2.25. (fromfpf): Likewise. (fromfpl): Likewise. (ufromfp): Likewise. (ufromfpf): Likewise. (ufromfpl): Likewise. (fromfpx): Likewise. (fromfpxf): Likewise. (fromfpxl): Likewise. (ufromfpx): Likewise. (ufromfpxf): Likewise. (ufromfpxl): Likewise. * math/Makefile (libm-calls): Add s_fromfpF, s_ufromfpF, s_fromfpxF and s_ufromfpxF. * math/gen-fromfp-tests.py: New file. * math/gen-fromfp-tests-inputs: Likewise. * math/libm-test.inc: Include <stdint.h> (check_intmax_t): New function. (check_uintmax_t): Likewise. (struct test_fiu_M_data): New type. (struct test_fiu_U_data): Likewise. (RUN_TEST_fiu_M): New macro. (RUN_TEST_LOOP_fiu_M): Likewise. (RUN_TEST_fiu_U): Likewise. (RUN_TEST_LOOP_fiu_U): Likewise. (fromfp_test_data): New array. (fromfp_test): New function. (fromfpx_test_data): New array. (fromfpx_test): New function. (ufromfp_test_data): New array. (ufromfp_test): New function. (ufromfpx_test_data): New array. (ufromfpx_test): New function. (main): Call fromfp_test, fromfpx_test, ufromfp_test and ufromfpx_test. * math/gen-libm-test.pl (parse_args): Handle u, M and U descriptor characters. * math/test-tgmath-ret.c: Include <stdint.h>. (rm): New variable. (width): Likewise. (CHECK_RET_CONST_TYPE): Take extra arguments and pass them to called function. (CHECK_RET_CONST_FLOAT): Take extra arguments and pass them to CHECK_RET_CONST_TYPE. (CHECK_RET_CONST_DOUBLE): Likewise. (CHECK_RET_CONST_LDOUBLE): Likewise. (CHECK_RET_CONST): Take extra arguments and pass them to calls macros. (fromfp): New CHECK_RET_CONST call. (ufromfp): Likewise. (fromfpx): Likewise. (ufromfpx): Likewise. (do_test): Call check_return_fromfp, check_return_ufromfp, check_return_fromfpx and check_return_ufromfpx. * math/test-tgmath.c: Include <stdint.h> (NCALLS): Increase to 138. (F(compile_test)): Initialize i. Call fromfp functions. (F(fromfp)): New function. (F(fromfpx)): Likewise. (F(ufromfp)): Likewise. (F(ufromfpx)): Likewise. * manual/arith.texi (Rounding Functions): Document FP_INT_UPWARD, FP_INT_DOWNWARD, FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO, FP_INT_TONEAREST, fromfp, fromfpf, fromfpl, ufromfp, ufromfpf, ufromfpl, fromfpx, fromfpxf, fromfpxl, ufromfpx, ufromfpxf and ufromfpxl. * manual/libm-err-tab.pl (@all_functions): Add fromfp, fromfpx, ufromfp and ufromfpx. * math/fromfp.h: New file. * sysdeps/ieee754/dbl-64/s_fromfp.c: Likewise. * sysdeps/ieee754/dbl-64/s_fromfp_main.c: Likewise. * sysdeps/ieee754/dbl-64/s_fromfpx.c: Likewise. * sysdeps/ieee754/dbl-64/s_ufromfp.c: Likewise. * sysdeps/ieee754/dbl-64/s_ufromfpx.c: Likewise. * sysdeps/ieee754/flt-32/s_fromfpf.c: Likewise. * sysdeps/ieee754/flt-32/s_fromfpf_main.c: Likewise. * sysdeps/ieee754/flt-32/s_fromfpxf.c: Likewise. * sysdeps/ieee754/flt-32/s_ufromfpf.c: Likewise. * sysdeps/ieee754/flt-32/s_ufromfpxf.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_ufromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_ufromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fromfpl_main.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fromfpl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_ufromfpl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_ufromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fromfp, ufromfp, fromfpx and ufromfpx. (CFLAGS-nldbl-fromfp.c): New variable. (CFLAGS-nldbl-fromfpx.c): Likewise. (CFLAGS-nldbl-ufromfp.c): Likewise. (CFLAGS-nldbl-ufromfpx.c): Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include <stdint.h>. * sysdeps/ieee754/ldbl-opt/nldbl-fromfp.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-fromfpx.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-ufromfp.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-ufromfpx.c: Likewise. * sysdeps/nacl/libm.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
427 lines
14 KiB
Plaintext
427 lines
14 KiB
Plaintext
/* Integer inputs within range of uintmax_t. */
|
|
i 1:1
|
|
i -1:1
|
|
i 2:2
|
|
i -2:2
|
|
i 3:2
|
|
i -3:3
|
|
i 4:3
|
|
i -4:3
|
|
i 5:3
|
|
i -5:4
|
|
i 6:3
|
|
i -6:4
|
|
i 7:3
|
|
i -7:4
|
|
i 8:4
|
|
i -8:4
|
|
i 9:4
|
|
i -9:5
|
|
i 15:4
|
|
i -15:5
|
|
i 16:5
|
|
i -16:5
|
|
i 17:5
|
|
i -17:6
|
|
i 0x3fffff:22
|
|
i -0x3fffff:23
|
|
i 0x400000:23
|
|
i -0x400000:23
|
|
i 0x400001:23
|
|
i -0x400001:24
|
|
i 0x7fffff:23
|
|
i -0x7fffff:24
|
|
i 0x800000:24
|
|
i -0x800000:24
|
|
i 0x800001:24
|
|
i -0x800001:25
|
|
i 0xffffff:24
|
|
i -0xffffff:25
|
|
i 0x1000000:25
|
|
i -0x1000000:25
|
|
#if MANT_DIG >= 53
|
|
i 0x1000001:25
|
|
i -0x1000001:26
|
|
i 0x7ffffffffffffLL:51
|
|
i -0x7ffffffffffffLL:52
|
|
#endif
|
|
i 0x8000000000000LL:52
|
|
i -0x8000000000000LL:52
|
|
#if MANT_DIG >= 53
|
|
i 0x8000000000001LL:52
|
|
i -0x8000000000001LL:53
|
|
i 0xfffffffffffffLL:52
|
|
i -0xfffffffffffffLL:53
|
|
#endif
|
|
i 0x10000000000000LL:53
|
|
i -0x10000000000000LL:53
|
|
#if MANT_DIG >= 53
|
|
i 0x10000000000001LL:53
|
|
i -0x10000000000001LL:54
|
|
i 0x1fffffffffffffLL:53
|
|
i -0x1fffffffffffffLL:54
|
|
#endif
|
|
i 0x20000000000000LL:54
|
|
i -0x20000000000000LL:54
|
|
#if MANT_DIG >= 64
|
|
i 0x20000000000001LL:54
|
|
i -0x20000000000001LL:55
|
|
i 0x3fffffffffffffffLL:62
|
|
i -0x3fffffffffffffffLL:63
|
|
#endif
|
|
i 0x4000000000000000LL:63
|
|
i -0x4000000000000000LL:63
|
|
#if MANT_DIG >= 64
|
|
i 0x4000000000000001LL:63
|
|
i -0x4000000000000001LL:64
|
|
i 0x7fffffffffffffffLL:63
|
|
i -0x7fffffffffffffffLL:64
|
|
#endif
|
|
i 0x8000000000000000ULL:64
|
|
i -INT64_MAX-1:64
|
|
#if MANT_DIG >= 64
|
|
i 0x8000000000000001ULL:64
|
|
i 0xffffffffffffffffULL:64
|
|
#endif
|
|
i 0x7fffff8000000000LL:63
|
|
i -0x7fffff8000000000LL:64
|
|
i 0x8000010000000000ULL:64
|
|
i 0xffffff0000000000ULL:64
|
|
#if MANT_DIG >= 53
|
|
i 0x7ffffffffffffc00LL:63
|
|
i -0x7ffffffffffffc00LL:64
|
|
i 0x8000000000000800ULL:64
|
|
i 0xfffffffffffff800ULL:64
|
|
#endif
|
|
|
|
/* Inputs with absolute value between 0 and 1. */
|
|
t min_subnorm_value a 0:1 1:1
|
|
t -min_subnorm_value a 0:1 -1:1
|
|
t min_value a 0:1 1:1
|
|
t -min_value a 0:1 -1:1
|
|
t 0.1 a 0:1 1:1
|
|
t -0.1 a 0:1 -1:1
|
|
t 0.25 a 0:1 1:1
|
|
t -0.25 a 0:1 -1:1
|
|
t 0.499 a 0:1 1:1
|
|
t -0.499 a 0:1 -1:1
|
|
t 0x0.ffffffp-1 a 0:1 1:1
|
|
t -0x0.ffffffp-1 a 0:1 -1:1
|
|
#if MANT_DIG >= 53
|
|
t 0x0.fffffffffffff8p-1 a 0:1 1:1
|
|
t -0x0.fffffffffffff8p-1 a 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 64
|
|
t 0x0.ffffffffffffffffp-1 a 0:1 1:1
|
|
t -0x0.ffffffffffffffffp-1 a 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 106
|
|
t 0x0.ffffffffffffffffffffffffffcp-1 a 0:1 1:1
|
|
t -0x0.ffffffffffffffffffffffffffcp-1 a 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 113
|
|
t 0x0.ffffffffffffffffffffffffffff8p-1 a 0:1 1:1
|
|
t -0x0.ffffffffffffffffffffffffffff8p-1 a 0:1 -1:1
|
|
#endif
|
|
t 0.5 be 0:1 1:1
|
|
t -0.5 be 0:1 -1:1
|
|
t 0x1.000002p-1 c 0:1 1:1
|
|
t -0x1.000002p-1 c 0:1 -1:1
|
|
#if MANT_DIG >= 53
|
|
t 0x1.0000000000001p-1 c 0:1 1:1
|
|
t -0x1.0000000000001p-1 c 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 64
|
|
t 0x1.0000000000000002p-1 c 0:1 1:1
|
|
t -0x1.0000000000000002p-1 c 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 106
|
|
t 0x1.000000000000000000000000008p-1 c 0:1 1:1
|
|
t -0x1.000000000000000000000000008p-1 c 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 113
|
|
t 0x1.0000000000000000000000000001p-1 c 0:1 1:1
|
|
t -0x1.0000000000000000000000000001p-1 c 0:1 -1:1
|
|
#endif
|
|
t 0.501 c 0:1 1:1
|
|
t -0.501 c 0:1 -1:1
|
|
t 0.75 c 0:1 1:1
|
|
t -0.75 c 0:1 -1:1
|
|
t 0.9 c 0:1 1:1
|
|
t -0.9 c 0:1 -1:1
|
|
t 0x0.ffffffp0 c 0:1 1:1
|
|
t -0x0.ffffffp0 c 0:1 -1:1
|
|
#if MANT_DIG >= 53
|
|
t 0x0.fffffffffffff8p0 c 0:1 1:1
|
|
t -0x0.fffffffffffff8p0 c 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 64
|
|
t 0x0.ffffffffffffffffp0 c 0:1 1:1
|
|
t -0x0.ffffffffffffffffp0 c 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 106
|
|
t 0x0.ffffffffffffffffffffffffffcp0 c 0:1 1:1
|
|
t -0x0.ffffffffffffffffffffffffffcp0 c 0:1 -1:1
|
|
#endif
|
|
#if MANT_DIG >= 113
|
|
t 0x0.ffffffffffffffffffffffffffff8p0 c 0:1 1:1
|
|
t -0x0.ffffffffffffffffffffffffffff8p0 c 0:1 -1:1
|
|
#endif
|
|
|
|
/* Various non-integer inputs. */
|
|
t 1.25 a 1:1 2:2
|
|
t -1.25 a -1:1 -2:2
|
|
t 1.5 bo 1:1 2:2
|
|
t -1.5 bo -1:1 -2:2
|
|
t 1.75 c 1:1 2:2
|
|
t -1.75 c -1:1 -2:2
|
|
t 2.25 a 2:2 3:2
|
|
t -2.25 a -2:2 -3:3
|
|
t 2.5 be 2:2 3:2
|
|
t -2.5 be -2:2 -3:3
|
|
t 2.75 c 2:2 3:2
|
|
t -2.75 c -2:2 -3:3
|
|
t 3.25 a 3:2 4:3
|
|
t -3.25 a -3:3 -4:3
|
|
t 3.5 bo 3:2 4:3
|
|
t -3.5 bo -3:3 -4:3
|
|
t 3.75 c 3:2 4:3
|
|
t -3.75 c -3:3 -4:3
|
|
t 4.25 a 4:3 5:3
|
|
t -4.25 a -4:3 -5:4
|
|
t 4.5 be 4:3 5:3
|
|
t -4.5 be -4:3 -5:4
|
|
t 4.75 c 4:3 5:3
|
|
t -4.75 c -4:3 -5:4
|
|
t 5.25 a 5:3 6:3
|
|
t -5.25 a -5:4 -6:4
|
|
t 5.5 bo 5:3 6:3
|
|
t -5.5 bo -5:4 -6:4
|
|
t 5.75 c 5:3 6:3
|
|
t -5.75 c -5:4 -6:4
|
|
|
|
/* 1, 1.5, 2, 2.5, 3, 3.5 +/- 1ulp. */
|
|
t 0x1.000002p0 a 1:1 2:2
|
|
t -0x1.000002p0 a -1:1 -2:2
|
|
t 0x2.fffffcp-1 a 1:1 2:2
|
|
t -0x2.fffffcp-1 a -1:1 -2:2
|
|
t 0x3.000004p-1 c 1:1 2:2
|
|
t -0x3.000004p-1 c -1:1 -2:2
|
|
t 0x0.ffffffp1 c 1:1 2:2
|
|
t -0x0.ffffffp1 c -1:1 -2:2
|
|
t 0x1.000002p1 a 2:2 3:2
|
|
t -0x1.000002p1 a -2:2 -3:3
|
|
t 0x4.fffff8p-1 a 2:2 3:2
|
|
t -0x4.fffff8p-1 a -2:2 -3:3
|
|
t 0x5.000008p-1 c 2:2 3:2
|
|
t -0x5.000008p-1 c -2:2 -3:3
|
|
t 0x2.fffffcp0 c 2:2 3:2
|
|
t -0x2.fffffcp0 c -2:2 -3:3
|
|
t 0x3.000004p0 a 3:2 4:3
|
|
t -0x3.000004p0 a -3:3 -4:3
|
|
t 0x6.fffff8p-1 a 3:2 4:3
|
|
t -0x6.fffff8p-1 a -3:3 -4:3
|
|
t 0x7.000008p-1 c 3:2 4:3
|
|
t -0x7.000008p-1 c -3:3 -4:3
|
|
#if MANT_DIG >= 53
|
|
t 0x1.0000000000001p0 a 1:1 2:2
|
|
t -0x1.0000000000001p0 a -1:1 -2:2
|
|
t 0x2.ffffffffffffep-1 a 1:1 2:2
|
|
t -0x2.ffffffffffffep-1 a -1:1 -2:2
|
|
t 0x3.0000000000002p-1 c 1:1 2:2
|
|
t -0x3.0000000000002p-1 c -1:1 -2:2
|
|
t 0x0.fffffffffffff8p1 c 1:1 2:2
|
|
t -0x0.fffffffffffff8p1 c -1:1 -2:2
|
|
t 0x1.0000000000001p1 a 2:2 3:2
|
|
t -0x1.0000000000001p1 a -2:2 -3:3
|
|
t 0x4.ffffffffffffcp-1 a 2:2 3:2
|
|
t -0x4.ffffffffffffcp-1 a -2:2 -3:3
|
|
t 0x5.0000000000004p-1 c 2:2 3:2
|
|
t -0x5.0000000000004p-1 c -2:2 -3:3
|
|
t 0x2.ffffffffffffep0 c 2:2 3:2
|
|
t -0x2.ffffffffffffep0 c -2:2 -3:3
|
|
t 0x3.0000000000002p0 a 3:2 4:3
|
|
t -0x3.0000000000002p0 a -3:3 -4:3
|
|
t 0x6.ffffffffffffcp-1 a 3:2 4:3
|
|
t -0x6.ffffffffffffcp-1 a -3:3 -4:3
|
|
t 0x7.0000000000004p-1 c 3:2 4:3
|
|
t -0x7.0000000000004p-1 c -3:3 -4:3
|
|
#endif
|
|
#if MANT_DIG >= 64
|
|
t 0x1.0000000000000002p0 a 1:1 2:2
|
|
t -0x1.0000000000000002p0 a -1:1 -2:2
|
|
t 0x2.fffffffffffffffcp-1 a 1:1 2:2
|
|
t -0x2.fffffffffffffffcp-1 a -1:1 -2:2
|
|
t 0x3.0000000000000004p-1 c 1:1 2:2
|
|
t -0x3.0000000000000004p-1 c -1:1 -2:2
|
|
t 0x0.ffffffffffffffffp1 c 1:1 2:2
|
|
t -0x0.ffffffffffffffffp1 c -1:1 -2:2
|
|
t 0x1.0000000000000002p1 a 2:2 3:2
|
|
t -0x1.0000000000000002p1 a -2:2 -3:3
|
|
t 0x4.fffffffffffffff8p-1 a 2:2 3:2
|
|
t -0x4.fffffffffffffff8p-1 a -2:2 -3:3
|
|
t 0x5.0000000000000008p-1 c 2:2 3:2
|
|
t -0x5.0000000000000008p-1 c -2:2 -3:3
|
|
t 0x2.fffffffffffffffcp0 c 2:2 3:2
|
|
t -0x2.fffffffffffffffcp0 c -2:2 -3:3
|
|
t 0x3.0000000000000004p0 a 3:2 4:3
|
|
t -0x3.0000000000000004p0 a -3:3 -4:3
|
|
t 0x6.fffffffffffffff8p-1 a 3:2 4:3
|
|
t -0x6.fffffffffffffff8p-1 a -3:3 -4:3
|
|
t 0x7.0000000000000008p-1 c 3:2 4:3
|
|
t -0x7.0000000000000008p-1 c -3:3 -4:3
|
|
#endif
|
|
#if MANT_DIG >= 106
|
|
t 0x1.000000000000000000000000008p0 a 1:1 2:2
|
|
t -0x1.000000000000000000000000008p0 a -1:1 -2:2
|
|
t 0x2.ffffffffffffffffffffffffffp-1 a 1:1 2:2
|
|
t -0x2.ffffffffffffffffffffffffffp-1 a -1:1 -2:2
|
|
t 0x3.00000000000000000000000001p-1 c 1:1 2:2
|
|
t -0x3.00000000000000000000000001p-1 c -1:1 -2:2
|
|
t 0x0.ffffffffffffffffffffffffffcp1 c 1:1 2:2
|
|
t -0x0.ffffffffffffffffffffffffffcp1 c -1:1 -2:2
|
|
t 0x1.000000000000000000000000008p1 a 2:2 3:2
|
|
t -0x1.000000000000000000000000008p1 a -2:2 -3:3
|
|
t 0x4.fffffffffffffffffffffffffep-1 a 2:2 3:2
|
|
t -0x4.fffffffffffffffffffffffffep-1 a -2:2 -3:3
|
|
t 0x5.00000000000000000000000002p-1 c 2:2 3:2
|
|
t -0x5.00000000000000000000000002p-1 c -2:2 -3:3
|
|
t 0x2.ffffffffffffffffffffffffffp0 c 2:2 3:2
|
|
t -0x2.ffffffffffffffffffffffffffp0 c -2:2 -3:3
|
|
t 0x3.00000000000000000000000001p0 a 3:2 4:3
|
|
t -0x3.00000000000000000000000001p0 a -3:3 -4:3
|
|
t 0x6.fffffffffffffffffffffffffep-1 a 3:2 4:3
|
|
t -0x6.fffffffffffffffffffffffffep-1 a -3:3 -4:3
|
|
t 0x7.00000000000000000000000002p-1 c 3:2 4:3
|
|
t -0x7.00000000000000000000000002p-1 c -3:3 -4:3
|
|
#endif
|
|
#if MANT_DIG >= 113
|
|
t 0x1.0000000000000000000000000001p0 a 1:1 2:2
|
|
t -0x1.0000000000000000000000000001p0 a -1:1 -2:2
|
|
t 0x2.fffffffffffffffffffffffffffep-1 a 1:1 2:2
|
|
t -0x2.fffffffffffffffffffffffffffep-1 a -1:1 -2:2
|
|
t 0x3.0000000000000000000000000002p-1 c 1:1 2:2
|
|
t -0x3.0000000000000000000000000002p-1 c -1:1 -2:2
|
|
t 0x0.ffffffffffffffffffffffffffff8p1 c 1:1 2:2
|
|
t -0x0.ffffffffffffffffffffffffffff8p1 c -1:1 -2:2
|
|
t 0x1.0000000000000000000000000001p1 a 2:2 3:2
|
|
t -0x1.0000000000000000000000000001p1 a -2:2 -3:3
|
|
t 0x4.fffffffffffffffffffffffffffcp-1 a 2:2 3:2
|
|
t -0x4.fffffffffffffffffffffffffffcp-1 a -2:2 -3:3
|
|
t 0x5.0000000000000000000000000004p-1 c 2:2 3:2
|
|
t -0x5.0000000000000000000000000004p-1 c -2:2 -3:3
|
|
t 0x2.fffffffffffffffffffffffffffep0 c 2:2 3:2
|
|
t -0x2.fffffffffffffffffffffffffffep0 c -2:2 -3:3
|
|
t 0x3.0000000000000000000000000002p0 a 3:2 4:3
|
|
t -0x3.0000000000000000000000000002p0 a -3:3 -4:3
|
|
t 0x6.fffffffffffffffffffffffffffcp-1 a 3:2 4:3
|
|
t -0x6.fffffffffffffffffffffffffffcp-1 a -3:3 -4:3
|
|
t 0x7.0000000000000000000000000004p-1 c 3:2 4:3
|
|
t -0x7.0000000000000000000000000004p-1 c -3:3 -4:3
|
|
#endif
|
|
|
|
/* 31, 32, 33 fractional bits. */
|
|
#if MANT_DIG >= 53
|
|
t 0x200000.7ffffffep0 a 0x200000:22 0x200001:22
|
|
t -0x200000.7ffffffep0 a -0x200000:22 -0x200001:23
|
|
t 0x200000.8p0 be 0x200000:22 0x200001:22
|
|
t -0x200000.8p0 be -0x200000:22 -0x200001:23
|
|
t 0x200000.80000002p0 c 0x200000:22 0x200001:22
|
|
t -0x200000.80000002p0 c -0x200000:22 -0x200001:23
|
|
t 0x200001.7ffffffep0 a 0x200001:22 0x200002:22
|
|
t -0x200001.7ffffffep0 a -0x200001:23 -0x200002:23
|
|
t 0x200001.8p0 bo 0x200001:22 0x200002:22
|
|
t -0x200001.8p0 bo -0x200001:23 -0x200002:23
|
|
t 0x200001.80000002p0 c 0x200001:22 0x200002:22
|
|
t -0x200001.80000002p0 c -0x200001:23 -0x200002:23
|
|
t 0x3fffff.fffffffep0 c 0x3fffff:22 0x400000:23
|
|
t -0x3fffff.fffffffep0 c -0x3fffff:23 -0x400000:23
|
|
t 0x100000.7fffffffp0 a 0x100000:21 0x100001:21
|
|
t -0x100000.7fffffffp0 a -0x100000:21 -0x100001:22
|
|
t 0x100000.8p0 be 0x100000:21 0x100001:21
|
|
t -0x100000.8p0 be -0x100000:21 -0x100001:22
|
|
t 0x100000.80000001p0 c 0x100000:21 0x100001:21
|
|
t -0x100000.80000001p0 c -0x100000:21 -0x100001:22
|
|
t 0x100001.7fffffffp0 a 0x100001:21 0x100002:21
|
|
t -0x100001.7fffffffp0 a -0x100001:22 -0x100002:22
|
|
t 0x100001.8p0 bo 0x100001:21 0x100002:21
|
|
t -0x100001.8p0 bo -0x100001:22 -0x100002:22
|
|
t 0x100001.80000001p0 c 0x100001:21 0x100002:21
|
|
t -0x100001.80000001p0 c -0x100001:22 -0x100002:22
|
|
t 0x1fffff.ffffffffp0 c 0x1fffff:21 0x200000:22
|
|
t -0x1fffff.ffffffffp0 c -0x1fffff:22 -0x200000:22
|
|
t 0x80000.7fffffff8p0 a 0x80000:20 0x80001:20
|
|
t -0x80000.7fffffff8p0 a -0x80000:20 -0x80001:21
|
|
t 0x80000.8p0 be 0x80000:20 0x80001:20
|
|
t -0x80000.8p0 be -0x80000:20 -0x80001:21
|
|
t 0x80000.800000008p0 c 0x80000:20 0x80001:20
|
|
t -0x80000.800000008p0 c -0x80000:20 -0x80001:21
|
|
t 0x80001.7fffffff8p0 a 0x80001:20 0x80002:20
|
|
t -0x80001.7fffffff8p0 a -0x80001:21 -0x80002:21
|
|
t 0x80001.8p0 bo 0x80001:20 0x80002:20
|
|
t -0x80001.8p0 bo -0x80001:21 -0x80002:21
|
|
t 0x80001.800000008p0 c 0x80001:20 0x80002:20
|
|
t -0x80001.800000008p0 c -0x80001:21 -0x80002:21
|
|
t 0xfffff.ffffffff8p0 c 0xfffff:20 0x100000:21
|
|
t -0xfffff.ffffffff8p0 c -0xfffff:21 -0x100000:21
|
|
#endif
|
|
#if MANT_DIG >= 64
|
|
t 0x100000000.7ffffffep0 a 0x100000000LL:33 0x100000001LL:33
|
|
t -0x100000000.7ffffffep0 a -0x100000000LL:33 -0x100000001LL:34
|
|
t 0x100000000.8p0 be 0x100000000LL:33 0x100000001LL:33
|
|
t -0x100000000.8p0 be -0x100000000LL:33 -0x100000001LL:34
|
|
t 0x100000000.80000002p0 c 0x100000000LL:33 0x100000001LL:33
|
|
t -0x100000000.80000002p0 c -0x100000000LL:33 -0x100000001LL:34
|
|
t 0x100000001.7ffffffep0 a 0x100000001LL:33 0x100000002LL:33
|
|
t -0x100000001.7ffffffep0 a -0x100000001LL:34 -0x100000002LL:34
|
|
t 0x100000001.8p0 bo 0x100000001LL:33 0x100000002LL:33
|
|
t -0x100000001.8p0 bo -0x100000001LL:34 -0x100000002LL:34
|
|
t 0x100000001.80000002p0 c 0x100000001LL:33 0x100000002LL:33
|
|
t -0x100000001.80000002p0 c -0x100000001LL:34 -0x100000002LL:34
|
|
t 0x1ffffffff.fffffffep0 c 0x1ffffffffLL:33 0x200000000LL:34
|
|
t -0x1ffffffff.fffffffep0 c -0x1ffffffffLL:34 -0x200000000LL:34
|
|
t 0x80000000.7fffffffp0 a 0x80000000LL:32 0x80000001LL:32
|
|
t -0x80000000.7fffffffp0 a -0x80000000LL:32 -0x80000001LL:33
|
|
t 0x80000000.8p0 be 0x80000000LL:32 0x80000001LL:32
|
|
t -0x80000000.8p0 be -0x80000000LL:32 -0x80000001LL:33
|
|
t 0x80000000.80000001p0 c 0x80000000LL:32 0x80000001LL:32
|
|
t -0x80000000.80000001p0 c -0x80000000LL:32 -0x80000001LL:33
|
|
t 0x80000001.7fffffffp0 a 0x80000001LL:32 0x80000002LL:32
|
|
t -0x80000001.7fffffffp0 a -0x80000001LL:33 -0x80000002LL:33
|
|
t 0x80000001.8p0 bo 0x80000001LL:32 0x80000002LL:32
|
|
t -0x80000001.8p0 bo -0x80000001LL:33 -0x80000002LL:33
|
|
t 0x80000001.80000001p0 c 0x80000001LL:32 0x80000002LL:32
|
|
t -0x80000001.80000001p0 c -0x80000001LL:33 -0x80000002LL:33
|
|
t 0xffffffff.ffffffffp0 c 0xffffffffLL:32 0x100000000LL:33
|
|
t -0xffffffff.ffffffffp0 c -0xffffffffLL:33 -0x100000000LL:33
|
|
t 0x40000000.7fffffff8p0 a 0x40000000LL:31 0x40000001LL:31
|
|
t -0x40000000.7fffffff8p0 a -0x40000000LL:31 -0x40000001LL:32
|
|
t 0x40000000.8p0 be 0x40000000LL:31 0x40000001LL:31
|
|
t -0x40000000.8p0 be -0x40000000LL:31 -0x40000001LL:32
|
|
t 0x40000000.800000008p0 c 0x40000000LL:31 0x40000001LL:31
|
|
t -0x40000000.800000008p0 c -0x40000000LL:31 -0x40000001LL:32
|
|
t 0x40000001.7fffffff8p0 a 0x40000001LL:31 0x40000002LL:31
|
|
t -0x40000001.7fffffff8p0 a -0x40000001LL:32 -0x40000002LL:32
|
|
t 0x40000001.8p0 bo 0x40000001LL:31 0x40000002LL:31
|
|
t -0x40000001.8p0 bo -0x40000001LL:32 -0x40000002LL:32
|
|
t 0x40000001.800000008p0 c 0x40000001LL:31 0x40000002LL:31
|
|
t -0x40000001.800000008p0 c -0x40000001LL:32 -0x40000002LL:32
|
|
t 0x7fffffff.ffffffff8p0 c 0x7fffffffLL:31 0x80000000LL:32
|
|
t -0x7fffffff.ffffffff8p0 c -0x7fffffffLL:32 -0x80000000LL:32
|
|
#endif
|
|
|
|
/* Tests where overflow depends on the rounding mode. */
|
|
#if MANT_DIG >= 64
|
|
t 0x7fffffffffffffff.8p0 bo 0x7fffffffffffffffLL:63 0x8000000000000000ULL:64
|
|
#endif
|
|
#if MANT_DIG >= 72
|
|
t 0x7fffffffffffffff.7fp0 a 0x7fffffffffffffffLL:63 0x8000000000000000ULL:64
|
|
t 0x7fffffffffffffff.81p0 c 0x7fffffffffffffffLL:63 0x8000000000000000ULL:64
|
|
t 0xffffffffffffffff.7fp0 a 0xffffffffffffffffULL:64 0x10000000000000000ULL:65
|
|
t 0xffffffffffffffff.8p0 bo 0xffffffffffffffffULL:64 0x10000000000000000ULL:65
|
|
t 0xffffffffffffffff.81p0 c 0xffffffffffffffffULL:64 0x10000000000000000ULL:65
|
|
t -0x8000000000000000.7fp0 a -INT64_MAX-1:64 -0x8000000000000001LL:65
|
|
t -0x8000000000000000.8p0 be -INT64_MAX-1:64 -0x8000000000000001LL:65
|
|
t -0x8000000000000000.81p0 c -INT64_MAX-1:64 -0x8000000000000001LL:65
|
|
#endif
|