Subversion Repositories HelenOS-historic

Rev

Rev 829 | Rev 1031 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 829 Rev 835
Line 189... Line 189...
189
}
189
}
190
 
190
 
191
float64 divFloat64(float64 a, float64 b)
191
float64 divFloat64(float64 a, float64 b)
192
{
192
{
193
    float64 result;
193
    float64 result;
194
    __s32 aexp, bexp, cexp;
194
    __s64 aexp, bexp, cexp;
195
    __u64 afrac, bfrac, cfrac;
195
    __u64 afrac, bfrac, cfrac;
196
    __u64 remlo, remhi;
196
    __u64 remlo, remhi;
197
   
197
   
198
    result.parts.sign = a.parts.sign ^ b.parts.sign;
198
    result.parts.sign = a.parts.sign ^ b.parts.sign;
199
   
199
   
200
    if (isFloat64NaN(a)) {
200
    if (isFloat64NaN(a)) {
-
 
201
       
-
 
202
        if (isFloat64SigNaN(b)) {
-
 
203
            /*FIXME: SigNaN*/
-
 
204
            return b;
-
 
205
        }
-
 
206
       
201
        if (isFloat64SigNaN(a)) {
207
        if (isFloat64SigNaN(a)) {
202
            /*FIXME: SigNaN*/
208
            /*FIXME: SigNaN*/
203
        }
209
        }
204
        /*NaN*/
210
        /*NaN*/
205
        return a;
211
        return a;
Line 212... Line 218...
212
        /*NaN*/
218
        /*NaN*/
213
        return b;
219
        return b;
214
    }
220
    }
215
   
221
   
216
    if (isFloat64Infinity(a)) {
222
    if (isFloat64Infinity(a)) {
217
        if (isFloat64Infinity(b)) {
223
        if (isFloat64Infinity(b) || isFloat64Zero(b)) {
218
            /*FIXME: inf / inf */
224
            /*FIXME: inf / inf */
219
            result.binary = FLOAT64_NAN;
225
            result.binary = FLOAT64_NAN;
220
            return result;
226
            return result;
221
        }
227
        }
222
        /* inf / num */
228
        /* inf / num */
Line 257... Line 263...
257
    bexp = b.parts.exp;
263
    bexp = b.parts.exp;
258
   
264
   
259
    /* denormalized numbers */
265
    /* denormalized numbers */
260
    if (aexp == 0) {
266
    if (aexp == 0) {
261
        if (afrac == 0) {
267
        if (afrac == 0) {
262
        result.parts.exp = 0;
268
            result.parts.exp = 0;
263
        result.parts.fraction = 0;
269
            result.parts.fraction = 0;
264
        return result;
270
            return result;
265
        }
271
        }
266
        /* normalize it*/
272
        /* normalize it*/
267
       
273
       
268
        afrac <<= 1;
274
        aexp++;
269
            /* afrac is nonzero => it must stop */ 
275
            /* afrac is nonzero => it must stop */ 
270
        while (! (afrac & FLOAT64_HIDDEN_BIT_MASK) ) {
276
        while (! (afrac & FLOAT64_HIDDEN_BIT_MASK) ) {
271
            afrac <<= 1;
277
            afrac <<= 1;
272
            aexp--;
278
            aexp--;
273
        }
279
        }
274
    }
280
    }
275
 
281
 
276
    if (bexp == 0) {
282
    if (bexp == 0) {
277
        bfrac <<= 1;
283
        bexp++;
278
            /* bfrac is nonzero => it must stop */ 
284
            /* bfrac is nonzero => it must stop */ 
279
        while (! (bfrac & FLOAT64_HIDDEN_BIT_MASK) ) {
285
        while (! (bfrac & FLOAT64_HIDDEN_BIT_MASK) ) {
280
            bfrac <<= 1;
286
            bfrac <<= 1;
281
            bexp--;
287
            bexp--;
282
        }
288
        }