string test alignment fix by Mahesh Bodapati
[libc-test.git] / src / regression / printf-fmt-g-round.c
blobc5f9a085388fb17933fea73b89fc5eb62dce132a
1 // commit e94d0692864ecf9522fd6a97610a47a2f718d3de 2014-04-07
2 // %g midpoint cases should be rounded to even
3 #include <stdio.h>
4 #include <string.h>
5 #include "test.h"
7 static void t(const char *fmt, double d, const char *want)
9 char buf[256];
10 int n = strlen(want);
11 int r = snprintf(buf, sizeof buf, fmt, d);
12 if (r != n || memcmp(buf, want, n+1) != 0)
13 t_error("snprintf(\"%s\", %f) want %s got %s\n", fmt, d, want, buf);
16 int main()
18 t("%.12g", 1000000000005.0, "1e+12");
19 t("%.12g", 100000000002500.0, "1.00000000002e+14");
20 return t_status;