Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/src/libc/port/nan.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
#define	NANEXP	(2047<<20)
5
#define	NANMASK	(2047<<20)
6
#define	NANSIGN	(1<<31)
7
 
8
double
9
NaN(void)
10
{
11
	FPdbleword a;
12
 
13
	a.hi = NANEXP;
14
	a.lo = 1;
15
	return a.x;
16
}
17
 
18
int
19
isNaN(double d)
20
{
21
	FPdbleword a;
22
 
23
	a.x = d;
24
	if((a.hi & NANMASK) != NANEXP)
25
		return 0;
26
	return !isInf(d, 0);
27
}
28
 
29
double
30
Inf(int sign)
31
{
32
	FPdbleword a;
33
 
34
	a.hi = NANEXP;
35
	a.lo = 0;
36
	if(sign < 0)
37
		a.hi |= NANSIGN;
38
	return a.x;
39
}
40
 
41
int
42
isInf(double d, int sign)
43
{
44
	FPdbleword a;
45
 
46
	a.x = d;
47
	if(a.lo != 0)
48
		return 0;
49
	if(a.hi == NANEXP)
50
		return sign >= 0;
51
	if(a.hi == (NANEXP|NANSIGN))
52
		return sign <= 0;
53
	return 0;
54
}