Skip to Main content Skip to Navigation
Preprints, Working Papers, ...

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 that avoids these shortcomings without compromising performances.
Document type :
Preprints, Working Papers, ...
Complete list of metadata
Contributor : Frédéric Goualard Connect in order to contact the contributor
Submitted on : Friday, July 9, 2021 - 2:07:43 PM
Last modification on : Wednesday, October 13, 2021 - 3:52:05 PM
Long-term archiving on: : Sunday, October 10, 2021 - 7:27:21 PM


Files produced by the author(s)


  • HAL Id : hal-03282794, version 1


Frédéric Goualard. Drawing random floating-point numbers from an interval. 2021. ⟨hal-03282794⟩



Record views


Files downloads