---
name: "ns_rand"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/ns_rand"
---

# ns\_rand(3)

commands

## NAME

ns\_rand - commands

## SYNOPSIS

**ns\_rand** ?*max*?

## DESCRIPTION

ns\_rand generates a cryptographically-secure random number.  If  *max* is not specified, the random number is a floating-point value *n* such that *0.0 \<= n \< 1.0.* If *max* is specified, it must be a positive integer between 0 and 2147483647. The return value is an integer value such that *0 \<= n \<= (max - 1).* Internally ns\_rand is implemented with the [drand48(3)](/drand48/3.md) and [lrand48(3)](/lrand48/3.md) standard library functions.  An internal random seed is generated the first time ns\_rand is called after the server starts.

## EXAMPLES

 nscp\> ns\_rand\
  0\.39938485692

 nscp\> ns\_rand 10\
  7

## SEE ALSO

nsd(1), [info(n)](/info/n.md), [drand48(3)](/drand48/3.md), [lrand48(3)](/lrand48/3.md)

## KEYWORDS
