Skip to Main content Skip to Navigation
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

https://hal.archives-ouvertes.fr/hal-03282794
Contributor : Frédéric Goualard Connect in order to contact the contributor
Submitted on : Friday, December 3, 2021 - 2:10:16 PM
Last modification on : Wednesday, January 19, 2022 - 3:48:22 PM

File

rand-in-range.pdf
Files produced by the author(s)

Identifiers

  • HAL Id : hal-03282794, version 2

Citation

Frédéric Goualard. Drawing random floating-point numbers from an interval. ACM Transactions on Modeling and Computer Simulation, Association for Computing Machinery, In press. ⟨hal-03282794v2⟩

Share

Metrics

Les métriques sont temporairement indisponibles