NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ATTRIBUTES |STANDARDS |SEE ALSO |COLOPHON | |
drand48_r(3) Library Functions Manualdrand48_r(3)drand48_r, erand48_r, lrand48_r, nrand48_r, mrand48_r, jrand48_r, srand48_r, seed48_r, lcong48_r - generate uniformly distributed pseudo-random numbers reentrantly
Standard C library (libc,-lc)
#include <stdlib.h>int drand48_r(struct drand48_data *restrictbuffer,double *restrictresult);int erand48_r(unsigned shortxsubi[3],struct drand48_data *restrictbuffer,double *restrictresult);int lrand48_r(struct drand48_data *restrictbuffer,long *restrictresult);int nrand48_r(unsigned shortxsubi[3],struct drand48_data *restrictbuffer,long *restrictresult);int mrand48_r(struct drand48_data *restrictbuffer,long *restrictresult);int jrand48_r(unsigned shortxsubi[3],struct drand48_data *restrictbuffer,long *restrictresult);int srand48_r(long intseedval, struct drand48_data *buffer);int seed48_r(unsigned shortseed16v[3], struct drand48_data *buffer);int lcong48_r(unsigned shortparam[7], struct drand48_data *buffer); Feature Test Macro Requirements for glibc (seefeature_test_macros(7)): All functions shown above: /* glibc >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
These functions are the reentrant analogs of the functions described indrand48(3). Instead of modifying the global random generator state, they use the supplied databuffer. Before the first use, this struct must be initialized, for example, by filling it with zeros, or by calling one of the functionssrand48_r(),seed48_r(), orlcong48_r().
The return value is 0.
For an explanation of the terms used in this section, seeattributes(7). ┌──────────────────────────┬───────────────┬─────────────────────┐ │Interface│Attribute│Value│ ├──────────────────────────┼───────────────┼─────────────────────┤ │drand48_r(), │ Thread safety │ MT-Safe race:buffer │ │erand48_r(), │ │ │ │lrand48_r(), │ │ │ │nrand48_r(), │ │ │ │mrand48_r(), │ │ │ │jrand48_r(), │ │ │ │srand48_r(),seed48_r(), │ │ │ │lcong48_r() │ │ │ └──────────────────────────┴───────────────┴─────────────────────┘
GNU.
drand48(3),rand(3),random(3)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17drand48_r(3)Pages that refer to this page:rand(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |