File: signBit.c

package info (click to toggle)
mlton 20061107-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,828 kB
  • ctags: 61,118
  • sloc: ansic: 11,446; makefile: 1,339; sh: 1,160; lisp: 900; pascal: 256; asm: 97
file content (43 lines) | stat: -rw-r--r-- 606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "platform.h"

#if HAS_SIGNBIT

Int Real32_signBit (Real32 f) {
        return signbit (f);
}

Int Real64_signBit (Real64 d) {
        return signbit (d);
}

#else

#if (defined __i386__)

enum {
        R32_byte = 3,
        R64_byte = 7,
};

#elif (defined __ppc__ || defined __sparc__)

enum {
        R32_byte = 0,
        R64_byte = 0,
};

#else

#error Real_signBit not implemented

#endif

Int Real32_signBit (Real32 f) {
        return (((unsigned char *)&f)[R32_byte] & 0x80) >> 7;
}

Int Real64_signBit (Real64 d) {
        return (((unsigned char *)&d)[R64_byte] & 0x80) >> 7;
}

#endif