Changeset 7257


Ignore:
Timestamp:
Sep 19, 2007, 9:46:56 AM (12 years ago)
Author:
gb
Message:

%BIGNUM-RANDOM here, do 32 bits at a time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0709/ccl/level-0/l0-bignum64.lisp

    r5837 r7257  
    20682068
    20692069
     2070(defun %bignum-random (number state)
     2071  (let* ((ndigits (%bignum-length number))
     2072         (sign-index (1- ndigits)))
     2073    (declare (fixnum ndigits sign-index))
     2074    (with-bignum-buffers ((bignum ndigits))
     2075      (dotimes (i sign-index)
     2076        (setf (bignum-ref bignum i) (%next-random-seed state)))
     2077      (setf (bignum-ref bignum sign-index)
     2078            (logand #x7fffffff (the (unsigned-byte 32)
     2079                                 (%next-random-seed state))))
     2080      (let* ((result (mod bignum number)))
     2081        (if (eq result bignum)
     2082          (copy-uvector bignum)
     2083          result)))))
     2084
     2085
     2086
    20702087(defun logbitp (index integer)
    20712088  "Predicate returns T if bit index of integer is a 1."
Note: See TracChangeset for help on using the changeset viewer.