Share via


Random.NextLong Method

Definition

Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.

[Android.Runtime.Register("nextLong", "()J", "GetNextLongHandler")]
public virtual long NextLong ();
[<Android.Runtime.Register("nextLong", "()J", "GetNextLongHandler")>]
abstract member NextLong : unit -> int64
override this.NextLong : unit -> int64

Returns

the next pseudorandom, uniformly distributed long value from this random number generator's sequence

Attributes

Remarks

Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence. The general contract of nextLong is that one long value is pseudorandomly generated and returned.

The method nextLong is implemented by class Random as if by:

{@code
            public long nextLong() {
              return ((long)next(32) << 32) + next(32);
            }}

Because class Random uses a seed with only 48 bits, this algorithm will not return all possible long values.

Java documentation for java.util.Random.nextLong().

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