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 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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
33 for (cnt
= 0; cnt
< 200; ++cnt
)
38 n
= sprintf (buf
, "%d", cnt
);
39 memset (buf
+ n
, '0', cnt
);
40 sprintf (buf
+ n
+ cnt
, ".000e-%d", cnt
);
41 f
= strtof (buf
, NULL
);
45 printf ("strtof(\"%s\") failed for cnt == %d (%g instead of %g)\n",
46 buf
, cnt
, f
, (float) cnt
);
50 printf ("strtof() fine for cnt == %d\n", cnt
);
53 for (cnt
= 0; cnt
< 200; ++cnt
)
58 n
= sprintf (buf
, "%d", cnt
);
59 memset (buf
+ n
, '0', cnt
);
60 sprintf (buf
+ n
+ cnt
, ".000e-%d", cnt
);
61 f
= strtod (buf
, NULL
);
63 if (f
!= (double) cnt
)
65 printf ("strtod(\"%s\") failed for cnt == %d (%g instead of %g)\n",
66 buf
, cnt
, f
, (double) cnt
);
70 printf ("strtod() fine for cnt == %d\n", cnt
);
73 for (cnt
= 0; cnt
< 200; ++cnt
)
78 n
= sprintf (buf
, "%d", cnt
);
79 memset (buf
+ n
, '0', cnt
);
80 sprintf (buf
+ n
+ cnt
, ".000e-%d", cnt
);
81 f
= strtold (buf
, NULL
);
83 if (f
!= (long double) cnt
)
85 printf ("strtold(\"%s\") failed for cnt == %d (%Lg instead of %Lg)\n",
86 buf
, cnt
, f
, (long double) cnt
);
90 printf ("strtold() fine for cnt == %d\n", cnt
);