x86_64: refresh ULPs
[uclibc-ng.git] / libm / nan.c
blobeee3b1cc48269bf9ac978d6fa8e70ac15977a15c
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
8 /***********************************************************************
9 nan, nanf, nanl - return quiet NaN
11 These functions shall return a quiet NaN, if available, with content
12 indicated through tagp.
14 If the implementation does not support quiet NaNs, these functions
15 shall return zero.
17 Calls: strlen(), sprintf(), strtod()
19 ***********************************************************************/
20 #include <math.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <stdio.h>
25 double nan (const char *tagp)
27 if (tagp[0] != '\0') {
28 char buf[6 + strlen (tagp)];
29 sprintf (buf, "NAN(%s)", tagp);
30 return strtod (buf, NULL);
32 return NAN;
34 libm_hidden_def(nan)
36 libm_hidden_proto(nanf)
37 float nanf (const char *tagp)
39 if (tagp[0] != '\0') {
40 char buf[6 + strlen (tagp)];
41 sprintf (buf, "NAN(%s)", tagp);
42 return strtof (buf, NULL);
44 return NAN;
46 libm_hidden_def(nanf)
48 #if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
49 libm_hidden_proto(nanl)
50 long double nanl (const char *tagp)
52 if (tagp[0] != '\0') {
53 char buf[6 + strlen (tagp)];
54 sprintf (buf, "NAN(%s)", tagp);
55 return strtold (buf, NULL);
57 return NAN;
59 libm_hidden_def(nanl)
60 #endif