I need to use random function with integer argument that I get from operations that theoretically can return double. So I want use some cast/round for this purpose. I’ve tried
(random (round 10.0))
(random (floor 10.0))
But it throws exceptions like
random: expects argument of type <exact integer in [1, 4294967087] or pseudo-random-generator>; given 10.0
I use DrRacket as interpreter.
Try
(random (floor->exact 10.0))or(random (inexact->exact (round 10.0))))You can use any of the roundings (floor/round/truncate/ceiling).
This is discussed here: http://web.mit.edu/scheme_v9.0.1/doc/mit-scheme-ref/Numerical-operations.html
(search for “inexact->exact”)