mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 21:10:27 +02:00
(*): Exercise multiply by exact 0 giving exact 0.
This commit is contained in:
parent
1527281c3a
commit
0202ead8ed
1 changed files with 43 additions and 1 deletions
|
@ -2459,10 +2459,52 @@
|
||||||
|
|
||||||
(with-test-prefix "*"
|
(with-test-prefix "*"
|
||||||
|
|
||||||
|
(with-test-prefix "inum * bignum"
|
||||||
|
|
||||||
|
(pass-if "0 * 2^256 = 0"
|
||||||
|
(eqv? 0 (* 0 (ash 1 256)))))
|
||||||
|
|
||||||
|
(with-test-prefix "inum * flonum"
|
||||||
|
|
||||||
|
(pass-if "0 * 1.0 = 0"
|
||||||
|
(eqv? 0 (* 0 1.0))))
|
||||||
|
|
||||||
|
(with-test-prefix "inum * complex"
|
||||||
|
|
||||||
|
(pass-if "0 * 1+1i = 0"
|
||||||
|
(eqv? 0 (* 0 1+1i))))
|
||||||
|
|
||||||
|
(with-test-prefix "inum * frac"
|
||||||
|
|
||||||
|
(pass-if "0 * 2/3 = 0"
|
||||||
|
(eqv? 0 (* 0 2/3))))
|
||||||
|
|
||||||
|
(with-test-prefix "bignum * inum"
|
||||||
|
|
||||||
|
(pass-if "2^256 * 0 = 0"
|
||||||
|
(eqv? 0 (* (ash 1 256) 0))))
|
||||||
|
|
||||||
|
(with-test-prefix "flonum * inum"
|
||||||
|
|
||||||
|
;; in guile 1.6.8 and 1.8.1 and earlier this returned inexact 0.0
|
||||||
|
(pass-if "1.0 * 0 = 0"
|
||||||
|
(eqv? 0 (* 1.0 0))))
|
||||||
|
|
||||||
|
(with-test-prefix "complex * inum"
|
||||||
|
|
||||||
|
;; in guile 1.6.8 and 1.8.1 and earlier this returned inexact 0.0
|
||||||
|
(pass-if "1+1i * 0 = 0"
|
||||||
|
(eqv? 0 (* 1+1i 0))))
|
||||||
|
|
||||||
(pass-if "complex * bignum"
|
(pass-if "complex * bignum"
|
||||||
(let ((big (ash 1 90)))
|
(let ((big (ash 1 90)))
|
||||||
(= (make-rectangular big big)
|
(= (make-rectangular big big)
|
||||||
(* 1+1i big)))))
|
(* 1+1i big))))
|
||||||
|
|
||||||
|
(with-test-prefix "frac * inum"
|
||||||
|
|
||||||
|
(pass-if "2/3 * 0 = 0"
|
||||||
|
(eqv? 0 (* 2/3 0)))))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; /
|
;;; /
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue