mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 10:16:17 +01:00
Fix to stupid bug in g_random_boolean, also both functions now return 1 or
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in g_random_boolean, also both functions now return 1 or 0 instead of 1<<15 or 0.
This commit is contained in:
parent
47412cbbc9
commit
08e47ea9f4
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -1,5 +1,11 @@
|
||||
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in
|
||||
g_random_boolean, also both functions now return 1 or 0 instead of
|
||||
1<<15 or 0.
|
||||
|
||||
* tests/rand-test.c: Extended testcases.
|
||||
|
||||
* configure.in: Remove G_HAVE_ISO_CXX_VARARGS and
|
||||
G_HAVE_ISO_C_VARARGS and define G_HAVE_ISO_VARARGS directly
|
||||
guarded by #if(n)def __cplusplus.
|
||||
|
@ -49,7 +49,7 @@ void g_rand_free (GRand *rand);
|
||||
void g_rand_set_seed (GRand *rand,
|
||||
guint32 seed);
|
||||
|
||||
#define g_rand_boolean(rand) (g_rand_int ((rand)) & (1<<15))
|
||||
#define g_rand_boolean(rand) ((g_rand_int (rand) & (1 << 15)) != 0)
|
||||
|
||||
guint32 g_rand_int (GRand *rand);
|
||||
gint32 g_rand_int_range (GRand *rand,
|
||||
@ -62,7 +62,7 @@ gdouble g_rand_double_range (GRand *rand,
|
||||
|
||||
void g_random_set_seed (guint32 seed);
|
||||
|
||||
#define g_random_boolean() (g_rand_boolean ((rand)))
|
||||
#define g_random_boolean() ((g_random_int () & (1 << 15)) != 0)
|
||||
|
||||
guint32 g_random_int (void);
|
||||
gint32 g_random_int_range (gint32 begin,
|
||||
|
4
grand.h
4
grand.h
@ -49,7 +49,7 @@ void g_rand_free (GRand *rand);
|
||||
void g_rand_set_seed (GRand *rand,
|
||||
guint32 seed);
|
||||
|
||||
#define g_rand_boolean(rand) (g_rand_int ((rand)) & (1<<15))
|
||||
#define g_rand_boolean(rand) ((g_rand_int (rand) & (1 << 15)) != 0)
|
||||
|
||||
guint32 g_rand_int (GRand *rand);
|
||||
gint32 g_rand_int_range (GRand *rand,
|
||||
@ -62,7 +62,7 @@ gdouble g_rand_double_range (GRand *rand,
|
||||
|
||||
void g_random_set_seed (guint32 seed);
|
||||
|
||||
#define g_random_boolean() (g_rand_boolean ((rand)))
|
||||
#define g_random_boolean() ((g_random_int () & (1 << 15)) != 0)
|
||||
|
||||
guint32 g_random_int (void);
|
||||
gint32 g_random_int_range (gint32 begin,
|
||||
|
@ -40,15 +40,31 @@ int main()
|
||||
{
|
||||
gint32 i;
|
||||
gdouble d;
|
||||
gboolean b;
|
||||
|
||||
i = g_rand_int_range (rand, 8,16);
|
||||
g_assert (i >= 8 && i < 16);
|
||||
|
||||
i = g_random_int_range (8,16);
|
||||
g_assert (i >= 8 && i < 16);
|
||||
|
||||
d = g_rand_double (rand);
|
||||
g_assert (d >= 0 && d < 1);
|
||||
|
||||
d = g_random_double ();
|
||||
g_assert (d >= 0 && d < 1);
|
||||
|
||||
d = g_rand_double_range (rand, -8, 32);
|
||||
g_assert (d >= -8 && d < 32);
|
||||
|
||||
d = g_random_double_range (-8, 32);
|
||||
g_assert (d >= -8 && d < 32);
|
||||
|
||||
b = g_random_boolean ();
|
||||
g_assert (b == TRUE || b == FALSE);
|
||||
|
||||
b = g_rand_boolean (rand);
|
||||
g_assert (b == TRUE || b == FALSE);
|
||||
}
|
||||
|
||||
g_rand_free (rand);
|
||||
|
Loading…
Reference in New Issue
Block a user