From: Szabolcs Nagy Date: Mon, 27 Jan 2014 13:15:56 +0000 (+0100) Subject: math/gen: yet another little decimal formatting tool X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=ff1a08c16ea49fa2bd3260a3b327b5dcaa5d13a6;ds=sidebyside math/gen: yet another little decimal formatting tool --- diff --git a/src/math/gen/Makefile b/src/math/gen/Makefile index 9be541d..ad1e280 100644 --- a/src/math/gen/Makefile +++ b/src/math/gen/Makefile @@ -8,7 +8,7 @@ T=$(wildcard t*.c) CC=musl-gcc #CC=gcc -all: gen check mgen tof toa toe tox next prev rnd +all: gen check mgen tof toa toe tog tox next prev rnd %:%.o %:%.c @@ -24,5 +24,5 @@ mgen: gen.c util.c mplibm.c $(CC) -o $@ $(CFLAGS) -lm $^ clean: - rm -f gen check mgen tof toa toe tox next prev rnd + rm -f gen check mgen tof toa toe tog tox next prev rnd diff --git a/src/math/gen/tog.c b/src/math/gen/tog.c new file mode 100644 index 0000000..ec0f687 --- /dev/null +++ b/src/math/gen/tog.c @@ -0,0 +1,25 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int i; + float f; + double d; + long double ld; + char *eptr; + + for (i = 1; i < argc; i++) { + errno = 0; + f = strtof(argv[i], &eptr); + printf("%.42g (*eptr:%d errno:%d)\n", f, *eptr, errno); + errno = 0; + d = strtod(argv[i], &eptr); + printf("%.42g (*eptr:%d errno:%d)\n", d, *eptr, errno); + errno = 0; + ld = strtold(argv[i], &eptr); + printf("%.42Lg (*eptr:%d errno:%d)\n", ld, *eptr, errno); + } + return 0; +}