Clozure Common Lisp Version 1.12 (v1.12) LinuxX8664 For more information about CCL, please see http://ccl.clozure.com. CCL is free software. It is distributed under the terms of the Apache Licence, Version 2.0. ;;; I shall redefine %FLOAT-RANDOM to signal an error in case the result is equal to the original number. ;;; Reference: https://github.com/Clozure/ccl/blob/8778079bd32e0ff9398d66d1b1da9c33641ddf1d/level-0/l0-numbers.lisp#L1970 ? (in-package :ccl) # ? (defun %float-random (number state) (let* ((old-state (make-random-state state)) (random-int (random target::target-most-positive-fixnum state)) (ratio (gvector :ratio random-int target::target-most-positive-fixnum))) (declare (dynamic-extent ratio)) (let ((result (* number ratio))) (if (= number result) (error "%FLOAT-RANDOM failure: ~S ~S ~S" result random-int old-state) result)))) %FLOAT-RANDOM ;;; Triggering the bug: ? (dotimes (i 1000000000) (random 57.0)) > Error: %FLOAT-RANDOM failure: 57.0 1152921472459506616 #.(INITIALIZE-MRG31K3P-STATE 267351351 1658092716 1369862252 257820909 1071609802 1939985399) > While executing: %FLOAT-RANDOM, in process listener(1). > Type :POP to abort, :R for a list of available restarts. > Type :? for other options. ;;; The error is because the random fixnum 1152921472459506616 was produced by the random state: 1 > (let ((*random-state* #.(INITIALIZE-MRG31K3P-STATE 267351351 1658092716 1369862252 257820909 1071609802 1939985399))) (random most-positive-fixnum)) 1152921472459506616 ;;; This number is dannnnnngerously close to MOST-POSITIVE-FIXNUM: 1 > most-positive-fixnum 1152921504606846975 1 > (/ 1152921472459506616 most-positive-fixnum) 1152921472459506616/1152921504606846975 1 > (float *) 1.0 ;; wow! 1 > (float ** 1.0d0) 0.999999972116627D0 ;;; And so, finally, (* 1152921472459506616/1152921504606846975 57.0) == 57.0 because of floating point rounding: 1 > (* 1152921472459506616/1152921504606846975 57.0) 57.0