CVS: sml-dist/src/system/smlnj/init core-intinf.sml,1.4,1.5
Matthias Blume <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj.commits |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/smlnj/sml-dist/src/system/smlnj/init
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30395/src/system/smlnj/init
Modified Files:
core-intinf.sml
Log Message:
fixed bug in IntInf.div
Index: core-intinf.sml
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/system/smlnj/init/core-intinf.sml,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** core-intinf.sml 11 Nov 2004 23:26:27 -0000 1.4
--- core-intinf.sml 4 May 2005 15:43:48 -0000 1.5
***************
*** 490,518 ****
(* divide DP number by digit; assumes u < i , i >= base/2 *)
! fun natdivmod2 ((u,v), i) = let
! fun low w = InLine.w31andb (w, maxDigitL)
! fun high w = InLine.w31rshiftl (w, hBaseBits)
! val vh = high v
! val vl = low v
! val ih = high i
! val il = low i
! val q1 = InLine.w31div (u, ih)
! val r1 = InLine.w31mod (u, ih)
! val x = InLine.w31add (InLine.w31lshift (r1, hBaseBits), vh)
! val y = InLine.w31mul (q1, il)
! val (q1, r1) = if InLine.w31ge (x, y) then (q1, InLine.w31sub (x, y))
! else (InLine.w31sub (q1, 0w1),
! InLine.w31sub (InLine.w31add (x, i), y))
! val q0 = InLine.w31div (r1, ih)
! val r0 = InLine.w31mod (r1, ih)
! val x = InLine.w31add (InLine.w31lshift (r0, hBaseBits), vl)
! val y = InLine.w31mul (q0, il)
! val (q0, r0) = if InLine.w31ge (x, y) then (q0, InLine.w31sub (x, y))
! else (InLine.w31sub (q0, 0w1),
! InLine.w31sub (InLine.w31add (x, i), y))
! in
! (InLine.w31add (InLine.w31lshift (q1, hBaseBits), q0), r0)
! end
(* divide bignat by digit>0 *)
--- 490,516 ----
(* divide DP number by digit; assumes u < i , i >= base/2 *)
! fun natdivmod2 ((u,v), i) =
! let fun low w = InLine.w31andb (w, maxDigitL)
! fun high w = InLine.w31rshiftl (w, hBaseBits)
! val (vh, vl) = (high v, low v)
! val (ih, il) = (high i, low i)
! fun adj (q, r, vx) =
! let val x = InLine.w31add (InLine.w31lshift (r, hBaseBits), vx)
! val y = InLine.w31mul (q, il)
! fun loop (q, x) =
! if InLine.w31ge (x, y) then (q, InLine.w31sub (x, y))
! else loop (InLine.w31sub (q, 0w1), InLine.w31add (x, i))
! in loop (q, x)
! end
!
! val q1 = InLine.w31div (u, ih)
! val r1 = InLine.w31mod (u, ih)
! val (q1, r1) = adj (q1, r1, vh)
! val q0 = InLine.w31div (r1, ih)
! val r0 = InLine.w31mod (r1, ih)
! val (q0, r0) = adj (q0, r0, vl)
! in (InLine.w31add (InLine.w31lshift (q1, hBaseBits), q0), r0)
! end
(* divide bignat by digit>0 *)
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20