// Copyright Naoki Shibata and contributors 2010 - 2021. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include "sleefquad.h" static void convertEndianness(void *ptr, int len) { #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) for(int k=0;k 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 13) #pragma GCC diagnostic ignored "-Wformat" #pragma GCC diagnostic ignored "-Wformat-extra-args" Sleef_registerPrintfHook(); static char buf[110]; Sleef_quad q = Sleef_strtoq("3.1415926535897932384626433832795028842", NULL); snprintf(buf, 100, "%50.40Pe", &q); if (strcmp(buf, " 3.1415926535897932384626433832795027974791e+00") != 0) { fprintf(stderr, "%%50.40Pe %s\n", buf); exit(-1); } snprintf(buf, 100, "%50.40Pf", &q); if (strcmp(buf, " 3.1415926535897932384626433832795027974791") != 0) { fprintf(stderr, "%%50.40Pf %s\n", buf); exit(-1); } snprintf(buf, 100, "%50.40Pg", &q); if (strcmp(buf, " 3.141592653589793238462643383279502797479") != 0) { fprintf(stderr, "%%50.40Pg %s\n", buf); exit(-1); } snprintf(buf, 100, "%Pa", &q); if (strcmp(buf, "0x1.921fb54442d18469898cc51701b8p+1") != 0) { fprintf(stderr, "%%Pa %s\n", buf); exit(-1); } #endif // FILE *fp = NULL; if (argc != 1) { fp = fopen(argv[1], "r"); if (fp == NULL) { fprintf(stderr, "Could not open %s\n", argv[1]); exit(-1); } } // static char *types[] = { "Pe", "Pf", "Pg", "Pa" }; static const char *strvals[] = { "1.2345678912345678912345e+0Q", "1.2345678912345678912345e+1Q", "1.2345678912345678912345e-1Q", "1.2345678912345678912345e+2Q", "1.2345678912345678912345e-2Q", "1.2345678912345678912345e+3Q", "1.2345678912345678912345e-3Q", "1.2345678912345678912345e+4Q", "1.2345678912345678912345e-4Q", "1.2345678912345678912345e+5Q", "1.2345678912345678912345e-5Q", "1.2345678912345678912345e+10Q", "1.2345678912345678912345e-10Q", "1.2345678912345678912345e+15Q", "1.2345678912345678912345e-15Q", "1.2345678912345678912345e+30Q", "1.2345678912345678912345e-30Q", "1.2345678912345678912345e+1000Q", "1.2345678912345678912345e-1000Q", "1.2345678912345678912345e-4950Q", "1.2345678912345678912345e+4920Q", "3.36210314311209350626267781732175260e-4932", "1.18973149535723176508575932662800702e+4932", "6.475175119438025110924438958227646552e-4966", "0.0Q", "1.0Q", "1e+1Q", "1e+2Q", "1e+3Q", "1e+4Q", "1e+5Q", "1e+6Q", "1e-1Q", "1e-2Q", "1e-3Q", "1e-4Q", "1e-5Q", "1e-6Q", "inf", "nan", }; Sleef_quad vals[sizeof(strvals) / sizeof(char *)]; for(int i=0;i