1// commit 89740868c9f1c84b8ee528468d12df1fa72cd392 2014-04-07
2// %g should not print trailing zeros
3#include <stdio.h>
4#include <string.h>
5#include "test.h"
6
7static void t(const char *fmt, double d, const char *want)
8{
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);
14}
15
16int main()
17{
18	t("%.50g", 100000000000000.5, "100000000000000.5");
19	t("%.50g", 987654321098765.0, "987654321098765");
20	return t_status;
21}
22