Skip to Main content Skip to Navigation
New interface
Journal articles

Drawing random floating-point numbers from an interval

Abstract : Drawing a floating-point number uniformly at random from an interval [a, b) is usually performed by a location-scale transformation of some floating-point number drawn uniformly from [0, 1). Due to the weak properties of floating-point arithmetic, such a transformation cannot ensure respect of the bounds, uniformity or spatial equidistributivity. We investigate and quantify precisely these shortcomings while reviewing the actual implementations of the method in major programming languages and libraries, and we propose a simple algorithm to avoid these shortcomings without compromising performances.
Document type :
Journal articles
Complete list of metadata
Contributor : Frédéric Goualard Connect in order to contact the contributor
Submitted on : Friday, October 7, 2022 - 3:09:45 PM
Last modification on : Thursday, October 13, 2022 - 3:54:15 AM


Files produced by the author(s)


  • HAL Id : hal-03282794, version 4


Frédéric Goualard. Drawing random floating-point numbers from an interval. ACM Transactions on Modeling and Computer Simulation, 2022, 32 (3). ⟨hal-03282794v4⟩



Record views


Files downloads