Rev 829 | Rev 1657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 829 | Rev 1031 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | * |
35 | * |
36 | */ |
36 | */ |
37 | float32 mulFloat32(float32 a, float32 b) |
37 | float32 mulFloat32(float32 a, float32 b) |
38 | { |
38 | { |
39 | float32 result; |
39 | float32 result; |
40 | __u64 frac1, frac2; |
40 | uint64_t frac1, frac2; |
41 | __s32 exp; |
41 | int32_t exp; |
42 | 42 | ||
43 | result.parts.sign = a.parts.sign ^ b.parts.sign; |
43 | result.parts.sign = a.parts.sign ^ b.parts.sign; |
44 | 44 | ||
45 | if (isFloat32NaN(a) || isFloat32NaN(b) ) { |
45 | if (isFloat32NaN(a) || isFloat32NaN(b) ) { |
46 | /* TODO: fix SigNaNs */ |
46 | /* TODO: fix SigNaNs */ |
Line 171... | Line 171... | ||
171 | * |
171 | * |
172 | */ |
172 | */ |
173 | float64 mulFloat64(float64 a, float64 b) |
173 | float64 mulFloat64(float64 a, float64 b) |
174 | { |
174 | { |
175 | float64 result; |
175 | float64 result; |
176 | __u64 frac1, frac2; |
176 | uint64_t frac1, frac2; |
177 | __s32 exp; |
177 | int32_t exp; |
178 | 178 | ||
179 | result.parts.sign = a.parts.sign ^ b.parts.sign; |
179 | result.parts.sign = a.parts.sign ^ b.parts.sign; |
180 | 180 | ||
181 | if (isFloat64NaN(a) || isFloat64NaN(b) ) { |
181 | if (isFloat64NaN(a) || isFloat64NaN(b) ) { |
182 | /* TODO: fix SigNaNs */ |
182 | /* TODO: fix SigNaNs */ |
Line 255... | Line 255... | ||
255 | * @param a first operand |
255 | * @param a first operand |
256 | * @param b second operand |
256 | * @param b second operand |
257 | * @param lo lower part from result |
257 | * @param lo lower part from result |
258 | * @param hi higher part of result |
258 | * @param hi higher part of result |
259 | */ |
259 | */ |
260 | void mul64integers(__u64 a,__u64 b, __u64 *lo, __u64 *hi) |
260 | void mul64integers(uint64_t a,uint64_t b, uint64_t *lo, uint64_t *hi) |
261 | { |
261 | { |
262 | __u64 low, high, middle1, middle2; |
262 | uint64_t low, high, middle1, middle2; |
263 | __u32 alow, blow; |
263 | uint32_t alow, blow; |
264 | 264 | ||
265 | alow = a & 0xFFFFFFFF; |
265 | alow = a & 0xFFFFFFFF; |
266 | blow = b & 0xFFFFFFFF; |
266 | blow = b & 0xFFFFFFFF; |
267 | 267 | ||
268 | a >>= 32; |
268 | a >>= 32; |
269 | b >>= 32; |
269 | b >>= 32; |
270 | 270 | ||
271 | low = ((__u64)alow) * blow; |
271 | low = ((uint64_t)alow) * blow; |
272 | middle1 = a * blow; |
272 | middle1 = a * blow; |
273 | middle2 = alow * b; |
273 | middle2 = alow * b; |
274 | high = a * b; |
274 | high = a * b; |
275 | 275 | ||
276 | middle1 += middle2; |
276 | middle1 += middle2; |
277 | high += (((__u64)(middle1 < middle2)) << 32) + (middle1 >> 32); |
277 | high += (((uint64_t)(middle1 < middle2)) << 32) + (middle1 >> 32); |
278 | middle1 <<= 32; |
278 | middle1 <<= 32; |
279 | low += middle1; |
279 | low += middle1; |
280 | high += (low < middle1); |
280 | high += (low < middle1); |
281 | *lo = low; |
281 | *lo = low; |
282 | *hi = high; |
282 | *hi = high; |