Partager via


StrictMath.Random Method

Definition

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.

[Android.Runtime.Register("random", "()D", "")]
public static double Random ();
[<Android.Runtime.Register("random", "()D", "")>]
static member Random : unit -> double

Returns

a pseudorandom double greater than or equal to 0.0 and less than 1.0.

Attributes

Remarks

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.

When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression

<blockquote>new java.util.Random()</blockquote>

This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else.

This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generate pseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-number generator.

Java documentation for java.lang.StrictMath.random().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to