# Rand

Return a random double between 0 and 1

## Method Signature

```
Rand(algorithm=[string])
```

### Arguments

| Argument    | Type     | Required | Description                                         | Default |
| ----------- | -------- | -------- | --------------------------------------------------- | ------- |
| `algorithm` | `string` | `false`  | The algorithm to use to generate the random number. |         |

## Examples

### simple example Using rand()

To generate a random number between 0 to 1

[Run Example](https://try.boxlang.io/?code=eJwrL8osSfUvLSkoLdFQKErMS9HQVNC05gIAaa4HiQ%3D%3D)

```java
writeOutput( rand() );

```

### simple example Using rand() with algorithm

To generate a random number between 0 to 1 by using bxmX\_COMPAT algorithm

```java
writeOutput( rand( "bxmX_COMPAT" ) );

```

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJwrL8osSXUpzS3QUChKzEvR0FSws1UwUFBTg3FtbBUMFTStucrRFCooBXs4GgYE%2BbkrKeDUBADz0hiR)

```java
writeDump( rand() >= 0 && rand() <= 1 );
writeDump( rand( "SHA1PRNG" ) >= 0 && rand() <= 1 );

```

## Related

* [Abs](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/abs)
* [Acos](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/acos)
* [Asin](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/asin)
* [Atn](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/atn)
* [Ceiling](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/ceiling)
* [Cos](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/cos)
* [DecrementValue](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/decrementvalue)
* [Exp](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/exp)
* [Fix](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/fix)
* [Floor](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/floor)
* [FormatBaseN](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/formatbasen)
* [IncrementValue](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/incrementvalue)
* [InputBaseN](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/inputbasen)
* [Int](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/int)
* [Log](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/log)
* [Log10](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/log10)
* [Max](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/max)
* [Min](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/min)
* [Pi](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/pi)
* [PrecisionEvaluate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/precisionevaluate)
* [Randomize](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/randomize)
* [RandRange](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/randrange)
* [Round](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/round)
* [Sgn](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/sgn)
* [Sin](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/sin)
* [Sqr](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/sqr)
* [Tan](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/math/tan)
