mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
(integer-length): Exercise some negatives, in
particular -2^n which is ...11100..00.
This commit is contained in:
parent
2cfcaed525
commit
a04a3604c2
1 changed files with 27 additions and 0 deletions
|
@ -1796,6 +1796,33 @@
|
|||
;;; inexact->exact
|
||||
;;;
|
||||
|
||||
;;;
|
||||
;;; integer-length
|
||||
;;;
|
||||
|
||||
(with-test-prefix "integer-length"
|
||||
|
||||
(with-test-prefix "-2^i, ...11100..00"
|
||||
(do ((n -1 (ash n 1))
|
||||
(i 0 (1+ i)))
|
||||
((> i 256))
|
||||
(pass-if (list n "expect" i)
|
||||
(= i (integer-length n)))))
|
||||
|
||||
(with-test-prefix "-2^i+1 ...11100..01"
|
||||
(do ((n -3 (logxor 3 (ash n 1)))
|
||||
(i 2 (1+ i)))
|
||||
((> i 256))
|
||||
(pass-if n
|
||||
(= i (integer-length n)))))
|
||||
|
||||
(with-test-prefix "-2^i-1 ...111011..11"
|
||||
(do ((n -2 (1+ (ash n 1)))
|
||||
(i 1 (1+ i)))
|
||||
((> i 256))
|
||||
(pass-if n
|
||||
(= i (integer-length n))))))
|
||||
|
||||
;;;
|
||||
;;; logcount
|
||||
;;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue