[c.math.rand]

# 29 Numerics library [[numerics]](./#numerics)

## 29.5 Random number generation [[rand]](rand#c.math.rand)

### 29.5.10 Low-quality random number generation [c.math.rand]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6923)

[*Note [1](#note-1)*:

The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2 Header <cstdlib> synopsis [cstdlib.syn]") declares the functions described in this subclause[.](#1.sentence-1)

â *end note*]

[ð](#lib:rand)

`int rand();
void srand(unsigned int seed);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6937)

*Effects*: Therand and srand functions have the semantics specified in the C standard library[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6943)

*Remarks*: The implementation
may specify that particular library functions may callrand[.](#3.sentence-1)

It is implementation-defined
whether the rand function
may introduce data races ([[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance"))[.](#3.sentence-2)

[*Note [2](#note-2)*:

The other random
number generation facilities in this document ([[rand]](rand "29.5 Random number generation")) are often preferable
to rand, because rand's underlying algorithm is unspecified[.](#3.sentence-3)

Use of rand therefore continues to be non-portable, with unpredictable
and oft-questionable quality and performance[.](#3.sentence-4)

â *end note*]

See also: ISO/IEC 9899:2024, 7.22.2
