include/elf.h: sync with GNU C library
[uclibc-ng.git] / libm / nan.c
blob454734b6f811dedf3ef62a7d26ce0764bb26f680
1 /*
2 * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 /***********************************************************************
8 nan, nanf, nanl - return quiet NaN
10 These functions shall return a quiet NaN, if available, with content
11 indicated through tagp.
13 If the implementation does not support quiet NaNs, these functions
14 shall return zero.
16 Calls: strlen(), sprintf(), strtod()
18 ***********************************************************************/
19 #include <math.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include <stdio.h>
24 double nan (const char *tagp)
26 if (tagp[0] != '\0') {
27 char buf[6 + strlen (tagp)];
28 sprintf (buf, "NAN(%s)", tagp);
29 return strtod (buf, NULL);
31 return NAN;
33 libm_hidden_def(nan)
35 libm_hidden_proto(nanf)
36 float nanf (const char *tagp)
38 if (tagp[0] != '\0') {
39 char buf[6 + strlen (tagp)];
40 sprintf (buf, "NAN(%s)", tagp);
41 return strtof (buf, NULL);
43 return NAN;
45 libm_hidden_def(nanf)
47 #if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
48 libm_hidden_proto(nanl)
49 long double nanl (const char *tagp)
51 if (tagp[0] != '\0') {
52 char buf[6 + strlen (tagp)];
53 sprintf (buf, "NAN(%s)", tagp);
54 return strtold (buf, NULL);
56 return NAN;
58 libm_hidden_def(nanl)
59 #endif