OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libm/] [nan.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/***********************************************************************
2
    nan, nanf, nanl - return quiet NaN
3
 
4
        These functions shall return a quiet NaN, if available, with content
5
        indicated through tagp.
6
 
7
        If the implementation does not support quiet NaNs, these functions
8
        shall return zero.
9
 
10
   Calls:  strlen(), sprintf(), strtod()
11
 
12
***********************************************************************/
13
#include <math.h>
14
#include <string.h>
15
#include <stdlib.h>
16
#include <stdio.h>
17
 
18
double nan (const char *tagp)
19
{
20
    if (tagp[0] != '\0') {
21
        char buf[6 + strlen (tagp)];
22
        sprintf (buf, "NAN(%s)", tagp);
23
        return strtod (buf, NULL);
24
    }
25
    return NAN;
26
}
27
 
28
float nanf (const char *tagp)
29
{
30
    if (tagp[0] != '\0') {
31
        char buf[6 + strlen (tagp)];
32
        sprintf (buf, "NAN(%s)", tagp);
33
        return strtof (buf, NULL);
34
    }
35
    return NAN;
36
}
37
 
38
#if 0
39
long double nanl (const char *tagp)
40
{
41
    if (tagp[0] != '\0') {
42
        char buf[6 + strlen (tagp)];
43
        sprintf (buf, "NAN(%s)", tagp);
44
        return strtold (buf, NULL);
45
    }
46
    return NAN;
47
}
48
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.