version 1.5, 2006/10/22 16:54:00
|
version 1.6, 2006/10/22 20:45:34
|
Line 116 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 (res.lo >= (UCell)CELL_MIN) |
if (res.lo > (UCell)CELL_MIN) |
throw(BALL_RESULTRANGE); |
throw(BALL_RESULTRANGE); |
if ((numsign^denomsign)<0) { |
if ((numsign^denomsign)<0) { |
|
res.lo = -res.lo; |
|
} else { |
if (res.lo == CELL_MIN) |
if (res.lo == CELL_MIN) |
throw(BALL_RESULTRANGE); |
throw(BALL_RESULTRANGE); |
res.lo = -res.lo; |
|
} |
} |
if (numsign<0) |
if (numsign<0) |
res.hi = -res.hi; |
res.hi = -res.hi; |
Line 133 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 (res.lo >= (UCell)CELL_MIN) |
if (numsign < 0) { |
throw(BALL_RESULTRANGE); |
if (res.lo < (UCell)CELL_MIN) |
|
throw(BALL_RESULTRANGE); |
|
} else { |
|
if (res.lo >= (UCell)CELL_MIN) |
|
throw(BALL_RESULTRANGE); |
|
} |
if (denomsign<0) |
if (denomsign<0) |
res.hi = -res.hi; |
res.hi = -res.hi; |
return res; |
return res; |