Diff for /gforth/engine/dblsub.c between versions 1.4 and 1.7

version 1.4, 2003/08/25 14:17:51 version 1.7, 2006/10/23 08:45:00
Line 81  UDCell umdiv (UDCell u, UCell v) Line 81  UDCell umdiv (UDCell u, UCell v)
   UCell q = 0, h = u.hi, l = u.lo;    UCell q = 0, h = u.hi, l = u.lo;
   UDCell res;    UDCell res;
   
     if (v==0)
       throw(BALL_DIVZERO);
     if (h>=v)
       throw(BALL_RESULTRANGE);
   for (;;)    for (;;)
     {      {
       if (c || h >= v)        if (c || h >= v)
Line 112  DCell smdiv (DCell num, Cell denom) /* s Line 116  DCell smdiv (DCell num, Cell denom) /* s
   if (denomsign < 0)    if (denomsign < 0)
     denom = -denom;      denom = -denom;
   res = UD2D(umdiv (D2UD(num), denom));    res = UD2D(umdiv (D2UD(num), denom));
   if ((numsign^denomsign)<0)    if ((numsign^denomsign)<0) {
     res.lo = -res.lo;      res.lo = -res.lo;
       if (((Cell)res.lo) > 0) /* note: == 0 is possible */
         throw(BALL_RESULTRANGE);
     } else {
       if (((Cell)res.lo) < 0)
         throw(BALL_RESULTRANGE);
     }
   if (numsign<0)    if (numsign<0)
     res.hi = -res.hi;      res.hi = -res.hi;
   return res;    return res;
Line 124  DCell fmdiv (DCell num, Cell denom) /* f Line 134  DCell fmdiv (DCell num, Cell denom) /* f
   /* I have this technique from Andrew Haley */    /* I have this technique from Andrew Haley */
   DCell res;    DCell res;
   Cell denomsign=denom;    Cell denomsign=denom;
     Cell numsign;
   
   if (denom < 0) {    if (denom < 0) {
     denom = -denom;      denom = -denom;
     num = dnegate(num);      num = dnegate(num);
   }    }
   if (num.hi < 0)    numsign = num.hi;
     if (numsign < 0)
     num.hi += denom;      num.hi += denom;
   res = UD2D(umdiv(D2UD(num),denom));    res = UD2D(umdiv(D2UD(num),denom));
     if ((numsign^((Cell)res.lo)) < 0)
       throw(BALL_RESULTRANGE);
   if (denomsign<0)    if (denomsign<0)
     res.hi = -res.hi;      res.hi = -res.hi;
   return res;    return res;

Removed from v.1.4  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>