Changeset f1f95f2 in mainline


Ignore:
Timestamp:
2006-02-13T23:06:04Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d9f51ccc
Parents:
d3ca210
Message:

Fixed bugs in 64bit float division.

Location:
softfloat/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • softfloat/generic/common.c

    rd3ca210 rf1f95f2  
    4848        };
    4949       
    50         cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3));
    51        
    5250        if ((cexp < 0) || ( cexp == 0 && (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_FRACTION_SIZE - 1)))))) {
    5351                /* FIXME: underflow */
    5452                result.parts.exp = 0;
    55                 if ((cexp + FLOAT64_FRACTION_SIZE) < 0) {
     53                if ((cexp + FLOAT64_FRACTION_SIZE + 1) < 0) { /* +1 is place for rounding */
    5654                        result.parts.fraction = 0;
    5755                        return result;
    5856                }
    59                 //cfrac >>= 1;
     57               
    6058                while (cexp < 0) {
    6159                        cexp++;
    6260                        cfrac >>= 1;
    6361                }
     62       
     63                cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3));
     64               
     65                if (!(cfrac & (FLOAT64_HIDDEN_BIT_MASK << (64 - FLOAT64_HIDDEN_BIT_MASK - 1)))) {
    6466                       
    65                 result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2) ) & (~FLOAT64_HIDDEN_BIT_MASK));
    66 
    67                 return result;
     67                        result.parts.fraction = ((cfrac >>(64 - FLOAT64_FRACTION_SIZE - 2) ) & (~FLOAT64_HIDDEN_BIT_MASK));
     68                        return result;
     69                }       
     70        } else {
     71                cfrac += (0x1 << (64 - FLOAT64_FRACTION_SIZE - 3));
    6872        }
    6973       
  • softfloat/generic/div.c

    rd3ca210 rf1f95f2  
    192192{
    193193        float64 result;
    194         __s32 aexp, bexp, cexp;
     194        __s64 aexp, bexp, cexp;
    195195        __u64 afrac, bfrac, cfrac;
    196196        __u64 remlo, remhi;
     
    199199       
    200200        if (isFloat64NaN(a)) {
     201               
     202                if (isFloat64SigNaN(b)) {
     203                        /*FIXME: SigNaN*/
     204                        return b;
     205                }
     206               
    201207                if (isFloat64SigNaN(a)) {
    202208                        /*FIXME: SigNaN*/
     
    215221       
    216222        if (isFloat64Infinity(a)) {
    217                 if (isFloat64Infinity(b)) {
     223                if (isFloat64Infinity(b) || isFloat64Zero(b)) {
    218224                        /*FIXME: inf / inf */
    219225                        result.binary = FLOAT64_NAN;
     
    260266        if (aexp == 0) {
    261267                if (afrac == 0) {
    262                 result.parts.exp = 0;
    263                 result.parts.fraction = 0;
    264                 return result;
     268                        result.parts.exp = 0;
     269                        result.parts.fraction = 0;
     270                        return result;
    265271                }
    266272                /* normalize it*/
    267273               
    268                 afrac <<= 1;
     274                aexp++;
    269275                        /* afrac is nonzero => it must stop */ 
    270276                while (! (afrac & FLOAT64_HIDDEN_BIT_MASK) ) {
     
    275281
    276282        if (bexp == 0) {
    277                 bfrac <<= 1;
     283                bexp++;
    278284                        /* bfrac is nonzero => it must stop */ 
    279285                while (! (bfrac & FLOAT64_HIDDEN_BIT_MASK) ) {
Note: See TracChangeset for help on using the changeset viewer.