1 /* Test iseqsig with excess precision. 2 Copyright (C) 2016-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <https://www.gnu.org/licenses/>. */ 18 19 #include <float.h> 20 #include <math.h> 21 #include <stdio.h> 22 23 static int do_test(void)24do_test (void) 25 { 26 int result = 0; 27 28 if (FLT_EVAL_METHOD == 1 || FLT_EVAL_METHOD == 2 || FLT_EVAL_METHOD > 32) 29 { 30 /* Excess precision for float. */ 31 if (iseqsig (1.0f, 1.0f + (float) DBL_EPSILON)) 32 { 33 puts ("iseqsig removes excess precision float -> double"); 34 result = 1; 35 } 36 else 37 puts ("iseqsig preserves excess precision float -> double"); 38 if (iseqsig (__builtin_inff (), FLT_MAX * FLT_MAX)) 39 { 40 puts ("iseqsig removes excess range float -> double"); 41 result = 1; 42 } 43 else 44 puts ("iseqsig preserves excess range float -> double"); 45 } 46 47 if (FLT_EVAL_METHOD == 2 || FLT_EVAL_METHOD > 64) 48 { 49 /* Excess precision for float and double. */ 50 if (iseqsig (1.0f, 1.0f + (float) LDBL_EPSILON)) 51 { 52 puts ("iseqsig removes excess precision float -> long double"); 53 result = 1; 54 } 55 else 56 puts ("iseqsig preserves excess precision float -> long double"); 57 if (iseqsig (1.0, 1.0 + (double) LDBL_EPSILON)) 58 { 59 puts ("iseqsig removes excess precision double -> long double"); 60 result = 1; 61 } 62 else 63 puts ("iseqsig preserves excess precision double -> long double"); 64 if (LDBL_MAX_EXP >= 2 * DBL_MAX_EXP) 65 { 66 if (iseqsig (__builtin_inf (), DBL_MAX * DBL_MAX)) 67 { 68 puts ("iseqsig removes excess range double -> long double"); 69 result = 1; 70 } 71 else 72 puts ("iseqsig preserves excess range double -> long double"); 73 } 74 } 75 76 return result; 77 } 78 79 #define TEST_FUNCTION do_test () 80 #include "../test-skeleton.c" 81