diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libkern/nan-sparc.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libkern/nan-sparc.c')
| -rw-r--r-- | libkern/nan-sparc.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/libkern/nan-sparc.c b/libkern/nan-sparc.c new file mode 100644 index 00000000..f1cfa0b0 --- /dev/null +++ b/libkern/nan-sparc.c @@ -0,0 +1,69 @@ +#include <lib9.h> + +#define NANEXP (2047<<20) +#define NANMASK (2047<<20) +#define NANSIGN (1<<31) + +double +NaN(void) +{ + union + { + double d; + long x[2]; + } a; + + a.x[0] = NANEXP; + a.x[1] = 1; + return a.d; +} + +int +isNaN(double d) +{ + union + { + double d; + long x[2]; + } a; + + a.d = d; + if((a.x[0] & NANMASK) != NANEXP) + return 0; + return !isInf(d, 0); +} + +double +Inf(int sign) +{ + union + { + double d; + long x[2]; + } a; + + a.x[0] = NANEXP; + a.x[1] = 0; + if(sign < 0) + a.x[0] |= NANSIGN; + return a.d; +} + +int +isInf(double d, int sign) +{ + union + { + double d; + long x[2]; + } a; + + a.d = d; + if(a.x[1] != 0) + return 0; + if(a.x[0] == NANEXP) + return sign >= 0; + if(a.x[0] == (NANEXP|NANSIGN)) + return sign <= 0; + return 0; +} |
