Rev 834 | Rev 1031 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 834 | Rev 835 | ||
---|---|---|---|
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 += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); |
- | |
51 | - | ||
52 | if ((cexp < 0) || ( cexp == 0 && (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1)))))) { |
50 | if ((cexp < 0) || ( cexp == 0 && (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1)))))) { |
53 | /* FIXME: underflow */ |
51 | /* FIXME: underflow */ |
54 | result.parts.exp = 0; |
52 | result.parts.exp = 0; |
55 | if ((cexp + FLOAT64_FRACTION_SIZE) < 0) { |
53 | if ((cexp + FLOAT64_FRACTION_SIZE + 1) < 0) { /* +1 is place for rounding */ |
56 | result.parts.fraction = 0; |
54 | result.parts.fraction = 0; |
57 | return result; |
55 | return result; |
58 | } |
56 | } |
59 | //cfrac >>= 1; |
57 | |
60 | while (cexp < 0) { |
58 | while (cexp < 0) { |
61 | cexp++; |
59 | cexp++; |
62 | cfrac >>= 1; |
60 | cfrac >>= 1; |
63 | } |
61 | } |
- | 62 | ||
- | 63 | cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); |
|
- | 64 | ||
- | 65 | if (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_HIDDEN_BIT_MASK - 1)))) { |
|
64 | 66 | ||
65 | result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2) ) & (~FLOAT64_HIDDEN_BIT_MASK)); |
67 | result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2) ) & (~FLOAT64_HIDDEN_BIT_MASK)); |
66 | - | ||
67 | return result; |
68 | return result; |
- | 69 | } |
|
- | 70 | } else { |
|
- | 71 | cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); |
|
68 | } |
72 | } |
69 | 73 | ||
70 | ++cexp; |
74 | ++cexp; |
71 | 75 | ||
72 | if (cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1 ))) { |
76 | if (cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1 ))) { |