xref: /third_party/musl/src/prng/drand48.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/prng/
1570af302Sopenharmony_ci#include <stdlib.h>
2570af302Sopenharmony_ci#include <inttypes.h>
3570af302Sopenharmony_ci#include "rand48.h"
4570af302Sopenharmony_ci
5570af302Sopenharmony_cidouble erand48(unsigned short s[3])
6570af302Sopenharmony_ci{
7570af302Sopenharmony_ci	union {
8570af302Sopenharmony_ci		uint64_t u;
9570af302Sopenharmony_ci		double f;
10570af302Sopenharmony_ci	} x = { 0x3ff0000000000000ULL | __rand48_step(s, __seed48+3)<<4 };
11570af302Sopenharmony_ci	return x.f - 1.0;
12570af302Sopenharmony_ci}
13570af302Sopenharmony_ci
14570af302Sopenharmony_cidouble drand48(void)
15570af302Sopenharmony_ci{
16570af302Sopenharmony_ci	return erand48(__seed48);
17570af302Sopenharmony_ci}
18

Indexes created Thu Nov 07 10:32:03 CST 2024