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.
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.
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.
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.
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.
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.
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.
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.
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,
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,
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,
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,
{
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);