Rev 237 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 237 | Rev 266 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | #include <print.h> |
30 | #include <print.h> |
31 | 31 | ||
32 | //TODO: |
32 | //TODO: |
33 | #define FMATH_MANTISA_MASK ( 0x000fffffffffffffLL ) |
33 | #define FMATH_MANTISA_MASK ( 0x000fffffffffffffLL ) |
34 | 34 | ||
35 | int fmath_is_negative(double num) |
- | |
36 | { //TODO: |
- | |
37 | /* fmath_ld_union_t fmath_ld_union; |
- | |
38 | fmath_ld_union.bf = num; |
- | |
39 | return ((fmath_ld_union.ldd[7])&0x80)==0x80; //first bit is sign, IA32 is little endian -> 8th byte |
- | |
40 | */ |
- | |
41 | return 0; |
- | |
42 | } |
- | |
43 | - | ||
44 | signed short fmath_get_binary_exponent(double num) |
35 | signed short fmath_get_binary_exponent(double num) |
45 | { //TODO: |
36 | { //TODO: |
46 | /* fmath_ld_union_t fmath_ld_union; |
37 | /* fmath_ld_union_t fmath_ld_union; |
47 | fmath_ld_union.bf = num; |
38 | fmath_ld_union.bf = num; |
48 | return (signed short)((((fmath_ld_union.ldd[7])&0x7f)<<4) + (((fmath_ld_union.ldd[6])&0xf0)>>4)) -FMATH_EXPONENT_BIAS; // exponent is 11 bits lenght, so sevent bits is in 8th byte and 4 bits in 7th |
39 | return (signed short)((((fmath_ld_union.ldd[7])&0x7f)<<4) + (((fmath_ld_union.ldd[6])&0xf0)>>4)) -FMATH_EXPONENT_BIAS; // exponent is 11 bits lenght, so sevent bits is in 8th byte and 4 bits in 7th |
Line 114... | Line 105... | ||
114 | */ |
105 | */ |
115 | 106 | ||
116 | return 0.0; |
107 | return 0.0; |
117 | }; |
108 | }; |
118 | 109 | ||
119 | double fmath_set_sign(double num,__u8 sign) |
- | |
120 | { //TODO: |
- | |
121 | /* fmath_ld_union_t fmath_ld_union; |
- | |
122 | fmath_ld_union.bf = num; |
- | |
123 | fmath_ld_union.ldd[7]=((fmath_ld_union.ldd[7])&0x7f)|(sign<<7); // change 64th bit (IA32 is a little endian) |
- | |
124 | return fmath_ld_union.bf; |
- | |
125 | */ return 1.0; |
- | |
126 | } |
- | |
127 | - | ||
128 | double fmath_abs(double num) |
- | |
129 | { //TODO: |
- | |
130 | /* |
- | |
131 | return fmath_set_sign(num,0); |
- | |
132 | */ |
- | |
133 | return 1.0; |
- | |
134 | } |
- | |
135 | 110 | ||
136 | double fmath_dpow(double base, double exponent) |
111 | double fmath_dpow(double base, double exponent) |
137 | { //TODO: |
112 | { //TODO: |
138 | /* double value=1.0; |
113 | /* double value=1.0; |
139 | if (base<=0.0) return base; |
114 | if (base<=0.0) return base; |
Line 155... | Line 130... | ||
155 | return value; |
130 | return value; |
156 | */ |
131 | */ |
157 | return 1.0; |
132 | return 1.0; |
158 | } |
133 | } |
159 | 134 | ||
- | 135 | ||
- | 136 | int fmath_is_nan(double num) |
|
- | 137 | { |
|
- | 138 | /* __u16 exp; |
|
- | 139 | fmath_ld_union_t fmath_ld_union; |
|
- | 140 | fmath_ld_union.bf = num; |
|
- | 141 | exp=(((fmath_ld_union.ldd[7])&0x7f)<<4) + (((fmath_ld_union.ldd[6])&0xf0)>>4); // exponent is 11 bits lenght, so sevent bits is in 8th byte and 4 bits in 7th |
|
- | 142 | ||
- | 143 | if (exp!=0x07ff) return 0; |
|
- | 144 | if (fmath_get_binary_mantisa(num)>=FMATH_NAN) return 1; |
|
- | 145 | |
|
- | 146 | */ |
|
- | 147 | return 0; |
|
- | 148 | } |
|
- | 149 | ||
- | 150 | int fmath_is_infinity(double num) |
|
- | 151 | { |
|
- | 152 | /* __u16 exp; |
|
- | 153 | fmath_ld_union_t fmath_ld_union; |
|
- | 154 | fmath_ld_union.bf = num; |
|
- | 155 | exp=(((fmath_ld_union.ldd[7])&0x7f)<<4) + (((fmath_ld_union.ldd[6])&0xf0)>>4); // exponent is 11 bits lenght, so sevent bits is in 8th byte and 4 bits in 7th |
|
- | 156 | ||
- | 157 | if (exp!=0x07ff) return 0; |
|
- | 158 | if (fmath_get_binary_mantisa(num)==0x0) return 1; |
|
- | 159 | */ return 0; |
|
- | 160 | } |
|
- | 161 |