Rev 829 | Rev 835 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 829 | Rev 834 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | cexp--; |
45 | cexp--; |
46 | cfrac <<= 1; |
46 | cfrac <<= 1; |
47 | /* TODO: fix underflow */ |
47 | /* TODO: fix underflow */ |
48 | }; |
48 | }; |
49 | 49 | ||
50 | cfrac >>= 1; |
- | |
51 | ++cexp; |
- | |
52 | cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); |
50 | cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); |
- | 51 | ||
- | 52 | if ((cexp < 0) || ( cexp == 0 && (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1)))))) { |
|
- | 53 | /* FIXME: underflow */ |
|
- | 54 | result.parts.exp = 0; |
|
- | 55 | if ((cexp + FLOAT64_FRACTION_SIZE) < 0) { |
|
- | 56 | result.parts.fraction = 0; |
|
- | 57 | return result; |
|
- | 58 | } |
|
- | 59 | //cfrac >>= 1; |
|
- | 60 | while (cexp < 0) { |
|
- | 61 | cexp++; |
|
- | 62 | cfrac >>= 1; |
|
- | 63 | } |
|
- | 64 | ||
- | 65 | result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2) ) & (~FLOAT64_HIDDEN_BIT_MASK)); |
|
- | 66 | ||
- | 67 | return result; |
|
- | 68 | } |
|
- | 69 | ||
- | 70 | ++cexp; |
|
53 | 71 | ||
54 | if (cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1 ))) { |
72 | if (cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1 ))) { |
55 | ++cexp; |
73 | ++cexp; |
56 | cfrac >>= 1; |
74 | cfrac >>= 1; |
57 | } |
75 | } |
58 | 76 | ||
59 | /* check overflow */ |
77 | /* check overflow */ |
60 | if (cexp >= FLOAT64_MAX_EXPONENT ) { |
78 | if (cexp >= FLOAT64_MAX_EXPONENT ) { |
61 | /* FIXME: overflow, return infinity */ |
79 | /* FIXME: overflow, return infinity */ |
62 | result.parts.exp = FLOAT64_MAX_EXPONENT; |
80 | result.parts.exp = FLOAT64_MAX_EXPONENT; |
63 | result.parts.fraction = 0; |
81 | result.parts.fraction = 0; |
64 | return result; |
82 | return result; |
65 | } |
83 | } |
66 | 84 | ||
67 | if (cexp < 0) { |
- | |
68 | /* FIXME: underflow */ |
- | |
69 | result.parts.exp = 0; |
- | |
70 | if ((cexp + FLOAT64_FRACTION_SIZE) < 0) { |
- | |
71 | result.parts.fraction = 0; |
- | |
72 | return result; |
- | |
73 | } |
- | |
74 | cfrac >>= 1; |
- | |
75 | while (cexp < 0) { |
- | |
76 | cexp ++; |
- | |
77 | cfrac >>= 1; |
- | |
78 | } |
- | |
79 | return result; |
- | |
80 | - | ||
81 | } else { |
- | |
82 | cexp ++; /*normalized*/ |
- | |
83 | result.parts.exp = (__u32)cexp; |
85 | result.parts.exp = (__u32)cexp; |
84 | } |
- | |
85 | 86 | ||
86 | result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2 ) ) & (~FLOAT64_HIDDEN_BIT_MASK)); |
87 | result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2 ) ) & (~FLOAT64_HIDDEN_BIT_MASK)); |
87 | 88 | ||
88 | return result; |
89 | return result; |
89 | } |
90 | } |
- | 91 |