added missing assertion check for (fxdiv (least-fixnum) -1)
and (fxdiv-and-mod (least-fixnum) -1).
This commit is contained in:
parent
2be7d93637
commit
930c713b76
|
@ -469,32 +469,29 @@
|
|||
($fx+ m0 m)
|
||||
($fx- m0 m))))))
|
||||
|
||||
(define (fxdiv-and-mod x y)
|
||||
(if (fixnum? x)
|
||||
(if (fixnum? y)
|
||||
(if ($fx= y 0)
|
||||
(die 'fxdiv-and-mod "division by 0")
|
||||
($fxdiv-and-mod x y))
|
||||
(die 'fxdiv-and-mod "not a fixnum" y))
|
||||
(die 'fxdiv-and-mod "not a fixnum" x)))
|
||||
(define-syntax define-div-proc
|
||||
(syntax-rules ()
|
||||
[(_ who $unsafe-op overflow-check?)
|
||||
(define (who x y)
|
||||
(if (fixnum? x)
|
||||
(if (fixnum? y)
|
||||
(if ($fx> y 0)
|
||||
($unsafe-op x y)
|
||||
(if ($fx= y 0)
|
||||
(die 'who "division by 0" x y)
|
||||
(if (and overflow-check? ($fx= y -1))
|
||||
(if ($fx= x (least-fixnum))
|
||||
(die 'who "result not representable as fixnum"
|
||||
x y)
|
||||
($unsafe-op x y))
|
||||
($unsafe-op x y))))
|
||||
(die 'who "not a fixnum" y))
|
||||
(die 'who "not a fixnum" x)))]))
|
||||
|
||||
(define (fxdiv x y)
|
||||
(if (fixnum? x)
|
||||
(if (fixnum? y)
|
||||
(if ($fx= y 0)
|
||||
(die 'fxdiv "division by 0")
|
||||
($fxdiv x y))
|
||||
(die 'fxdiv "not a fixnum" y))
|
||||
(die 'fxdiv "not a fixnum" x)))
|
||||
(define-div-proc fxdiv $fxdiv #t)
|
||||
(define-div-proc fxmod $fxmod #f)
|
||||
(define-div-proc fxdiv-and-mod $fxdiv-and-mod #t)
|
||||
|
||||
(define (fxmod x y)
|
||||
(if (fixnum? x)
|
||||
(if (fixnum? y)
|
||||
(if ($fx= y 0)
|
||||
(die 'fxmod "modision by 0")
|
||||
($fxmod x y))
|
||||
(die 'fxmod "not a fixnum" y))
|
||||
(die 'fxmod "not a fixnum" x)))
|
||||
|
||||
(define ($fxdiv0-and-mod0 n m)
|
||||
(let ([d0 (quotient n m)])
|
||||
|
|
|
@ -1 +1 @@
|
|||
1725
|
||||
1726
|
||||
|
|
Loading…
Reference in New Issue