1 /* Test to strtod etc for numbers like x000...0000.000e-nn.
2 This file is part of the GNU C Library.
3 Copyright (C) 2001-2014 Free Software Foundation, Inc.
4 Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
32 for (cnt
= 0; cnt
< 200; ++cnt
)
37 n
= sprintf (buf
, "%d", cnt
);
38 memset (buf
+ n
, '0', cnt
);
39 sprintf (buf
+ n
+ cnt
, ".000e-%d", cnt
);
40 f
= strtof (buf
, NULL
);
44 printf ("strtof(\"%s\") failed for cnt == %d (%g instead of %g)\n",
45 buf
, cnt
, f
, (float) cnt
);
49 printf ("strtof() fine for cnt == %d\n", cnt
);
52 for (cnt
= 0; cnt
< 200; ++cnt
)
57 n
= sprintf (buf
, "%d", cnt
);
58 memset (buf
+ n
, '0', cnt
);
59 sprintf (buf
+ n
+ cnt
, ".000e-%d", cnt
);
60 f
= strtod (buf
, NULL
);
62 if (f
!= (double) cnt
)
64 printf ("strtod(\"%s\") failed for cnt == %d (%g instead of %g)\n",
65 buf
, cnt
, f
, (double) cnt
);
69 printf ("strtod() fine for cnt == %d\n", cnt
);
72 for (cnt
= 0; cnt
< 200; ++cnt
)
77 n
= sprintf (buf
, "%d", cnt
);
78 memset (buf
+ n
, '0', cnt
);
79 sprintf (buf
+ n
+ cnt
, ".000e-%d", cnt
);
80 f
= strtold (buf
, NULL
);
82 if (f
!= (long double) cnt
)
84 printf ("strtold(\"%s\") failed for cnt == %d (%Lg instead of %Lg)\n",
85 buf
, cnt
, f
, (long double) cnt
);
89 printf ("strtold() fine for cnt == %d\n", cnt
);