Subversion Repositories shark

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/* Project:     OSLib
2
 * Description: The OS Construction Kit
3
 * Date:                1.6.2000
4
 * Idea by:             Luca Abeni & Gerardo Lamastra
5
 *
6
 * OSLib is an SO project aimed at developing a common, easy-to-use
7
 * low-level infrastructure for developing OS kernels and Embedded
8
 * Applications; it partially derives from the HARTIK project but it
9
 * currently is independently developed.
10
 *
11
 * OSLib is distributed under GPL License, and some of its code has
12
 * been derived from the Linux kernel source; also some important
13
 * ideas come from studying the DJGPP go32 extender.
14
 *
15
 * We acknowledge the Linux Community, Free Software Foundation,
16
 * D.J. Delorie and all the other developers who believe in the
17
 * freedom of software and ideas.
18
 *
19
 * For legalese, check out the included GPL license.
20
 */
21
 
22
#include <ll/ctype.h>
23
#include <ll/i386/string.h>
24
 
25
FILE(IsSpecial);
26
 
27
int isspecial(double d, char *bufp)
28
{
29
    /* IEEE standard number rapresentation */
30
    register struct IEEEdp {
31
        unsigned manl:32;
32
        unsigned manh:20;
33
        unsigned exp:11;
34
        unsigned sign:1;
35
    } *ip = (struct IEEEdp *) &d;
36
 
37
    if (ip->exp != 0x7ff)
38
        return (0);
39
    if (ip->manh || ip->manl) {
40
        if (bufp != NULL)
41
            strcpy(bufp, "NaN");
42
        return (1);
43
    } else if (ip->sign) {
44
        if (bufp != NULL)
45
            strcpy(bufp, "+Inf");
46
        return (2);
47
    } else {
48
        if (bufp != NULL)
49
            strcpy(bufp, "-Inf");
50
        return (3);
51
    }
52
}