[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Please hint athena-jot 9.0-3 in etch



The new release fixes a long standing random distribution issue
#378121 and updates policy/compat.

My patch for the above bug is as follows:

--- athena-jot-9.0.orig/jot.c 
+++ athena-jot-9.0/jot.c
@@ -108,13 +108,20 @@
        register double *y = &yd;
        register long   *i = &id;
 
+       int range; 
+       unsigned int randval;
+
        getargs(argc, argv);
        if (randomize) {
                *x = (ender - begin) * (ender > begin ? 1 : -1);
                srandom((int) s);
+               range = *x + 1;
                for (*i = 1; *i <= reps || infinity; (*i)++) {
-                       *y = (double) random() / INT_MAX;
-                       putdata(*y * *x + begin, reps - *i);
+                       do {
+                               randval = random();
+                       } while ( randval > RAND_MAX - (RAND_MAX % range));
+                       *y = (double) (randval % range);
+                       putdata(*y + begin, reps - *i);
                }
        }
        else

Cheers

-- 
Francesco P. Lovergine



Reply to: