7 releases

0.3.4 Jul 27, 2022
0.3.3 Jul 26, 2022
0.2.0 Feb 16, 2022
0.1.0 Jan 19, 2022

#601 in Algorithms


5.5K SLoC

C 5K SLoC // 0.4% comments Rust 252 SLoC // 0.0% comments Java 117 SLoC


A port of Java java.util.Random to Rust.

The implementation follows the public API of Java 17 Random. The method signatures have been changed to be more rusty, for example, nextInt -> next_i32, nextDouble -> next_f64, nextGaussian -> next_gaussian, etc. Jandom differs from other java Random implementations by having true feature parity, where even the next_gaussian method returns same values as the Java equivalent.

Jandom makes use of atomics and Mutex to be thread safe by default.

Example usages can be found in the examples directory.


If you find any discrepencies between this and the Java implementation, please file a Issue.


The code has been licensed under both MIT and Apache 2.0 to follow the Rust API guidelines.


Pseudorandom number generator implemented with the same algorithm and parameters as java.util.Random.

This crate has feature parity with the Java 17 implementation of Random. The crate includes the sources for fdlibm (freely distributable libm) which is used by StrictMath in Java.