mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 12:20:20 +02:00
though scm_c_random returns a ulong, it's only 32 random bits
* libguile/random.c (scm_c_random): Revert previous patch adapting to assume ulong-sized bits, as the RNGs really only give us 32 bits at a time. (scm_c_random_bignum): Adjust to expect random_bits giving us 32 bits at a time. * libguile/random.h: Add comments.
This commit is contained in:
parent
db6e848d19
commit
3bac8ddf92
2 changed files with 21 additions and 43 deletions
|
@ -3,7 +3,7 @@
|
|||
#ifndef SCM_RANDOM_H
|
||||
#define SCM_RANDOM_H
|
||||
|
||||
/* Copyright (C) 1999,2000,2001, 2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999,2000,2001, 2006, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -45,6 +45,7 @@ typedef struct scm_t_rstate {
|
|||
|
||||
typedef struct scm_t_rng {
|
||||
size_t rstate_size; /* size of random state */
|
||||
/* Though this returns an unsigned long, it's only 32 bits of randomness. */
|
||||
unsigned long (*random_bits) (scm_t_rstate *state); /* gives 32 random bits */
|
||||
void (*init_rstate) (scm_t_rstate *state, const char *seed, int n);
|
||||
scm_t_rstate *(*copy_rstate) (scm_t_rstate *state);
|
||||
|
@ -62,6 +63,7 @@ typedef struct scm_t_i_rstate {
|
|||
unsigned long c;
|
||||
} scm_t_i_rstate;
|
||||
|
||||
/* Though this returns an unsigned long, it's only 32 bits of randomness. */
|
||||
SCM_API unsigned long scm_i_uniform32 (scm_t_i_rstate *);
|
||||
SCM_API void scm_i_init_rstate (scm_t_i_rstate *, const char *seed, int n);
|
||||
SCM_API scm_t_i_rstate *scm_i_copy_rstate (scm_t_i_rstate *);
|
||||
|
@ -76,6 +78,7 @@ SCM_API scm_t_rstate *scm_c_default_rstate (void);
|
|||
SCM_API double scm_c_uniform01 (scm_t_rstate *);
|
||||
SCM_API double scm_c_normal01 (scm_t_rstate *);
|
||||
SCM_API double scm_c_exp1 (scm_t_rstate *);
|
||||
/* Though this returns an unsigned long, it's only 32 bits of randomness. */
|
||||
SCM_API unsigned long scm_c_random (scm_t_rstate *, unsigned long m);
|
||||
SCM_API SCM scm_c_random_bignum (scm_t_rstate *, SCM m);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue