Changeset 03362fbd in mainline for uspace/lib/softfloat/common.c
- Timestamp:
- 2013-02-09T23:14:45Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 22dfd38
- Parents:
- b5d2e57 (diff), 005b765 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/lib/softfloat/common.c (moved) (moved from uspace/lib/softfloat/generic/common.c ) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/softfloat/common.c
rb5d2e57 r03362fbd 34 34 */ 35 35 36 #include <sftypes.h>37 #include <common.h>36 #include "sftypes.h" 37 #include "common.h" 38 38 39 39 /* Table for fast leading zeroes counting. */ 40 40 char zeroTable[256] = { 41 8, 7, 7, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, \41 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, \ 42 42 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, \ 43 43 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \ … … 57 57 }; 58 58 59 /** 59 /** 60 60 * Take fraction shifted by 10 bits to the left, round it, normalize it 61 61 * and detect exceptions … … 75 75 while ((cexp > 0) && (cfrac) && 76 76 (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1))))) { 77 cexp--; 77 cexp--; 78 78 cfrac <<= 1; 79 79 /* TODO: fix underflow */ … … 110 110 ++cexp; 111 111 cfrac >>= 1; 112 } 112 } 113 113 114 114 /* check overflow */ … … 307 307 /** 308 308 * Round and normalize number expressed by exponent and fraction with 309 * first bit (equal to hidden bit) at 62nd bit.309 * first bit (equal to hidden bit) at bit 62. 310 310 * 311 311 * @param exp Exponent part. 312 * @param fraction Fraction with hidden bit shifted to 62nd bit.312 * @param fraction Fraction with hidden bit shifted to bit 62. 313 313 */ 314 314 void round_float64(int32_t *exp, uint64_t *fraction) 315 315 { 316 /* rounding - if first bit after fraction is set then round up */ 316 /* 317 * Rounding - if first bit after fraction is set then round up. 318 */ 319 320 /* 321 * Add 1 to the least significant bit of the fraction respecting the 322 * current shift to bit 62 and see if there will be a carry to bit 63. 323 */ 317 324 (*fraction) += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3)); 318 325 326 /* See if there was a carry to bit 63. */ 319 327 if ((*fraction) & 320 (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 3))) {328 (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1))) { 321 329 /* rounding overflow */ 322 330 ++(*exp);
Note:
See TracChangeset
for help on using the changeset viewer.
