Skip to content

Commit

Permalink
Merge pull request #37 from onflow/tarak/revertible-random
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Dec 29, 2023
2 parents fa20152 + 08bf240 commit 84ff950
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions versioned_docs/version-1.0/language/built-in-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ The message argument is optional.
## `revertibleRandom`

```cadence
view fun revertibleRandom(): UInt64
view fun revertibleRandom<T: FixedSizeUnsignedInteger>(modulo: T): T
```
Returns a pseudo-random integer.

`T` can be any fixed-size unsigned integer type (`FixedSizeUnsignedInteger`, i.e.
(`UInt8`, `UInt16`, `UInt32`, `UInt64`, `UInt128`, `UInt256`,
`Word8`, `Word16`, `Word32`, `Word64`, `Word128`, `Word256`).

The modulo argument is optional.
If provided, the returned integer is between `0` and `modulo -1`.
If not provided, the returned integer is between `0` and the maximum value of `T`.
The function errors if `modulo` is equal to 0.

Returns a pseudo-random number.

The sequence of returned random numbers is independent for
every transaction in each block.
Expand Down

0 comments on commit 84ff950

Please sign in to comment.