Files
cppdraft_translate/cppdraft/c/math/rand.md
2025-10-25 03:02:53 +03:00

1.6 KiB

[c.math.rand]

29 Numerics library [numerics]

29.5 Random number generation [rand]

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

1

#

[Note 1:

The header declares the functions described in this subclause.

— end note]

🔗

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

2

#

Effects: Therand and srand functions have the semantics specified in the C standard library.

3

#

Remarks: The implementation may specify that particular library functions may callrand.

It is implementation-defined whether the rand function may introduce data races ([res.on.data.races]).

[Note 2:

The other random number generation facilities in this document ([rand]) are often preferable to rand, because rand's underlying algorithm is unspecified.

Use of rand therefore continues to be non-portable, with unpredictable and oft-questionable quality and performance.

— end note]

See also: ISO/IEC 9899:2024, 7.22.2