[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-129-gcc9b375
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-129-gcc9b375 |
Date: |
Wed, 16 Oct 2013 04:31:59 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, master has been updated
via cc9b3756aa71d453f413279a579f403b756ebd97 (commit)
via f295225b9f1aa89ce2b318963ae8d0d9c27388f3 (commit)
via 598630d323cad5d3acb69cfba3b296b18ccbecf1 (commit)
via 2c76d05179339ca7100c0e5649dd2e0d50a0cb4c (commit)
via a7fd49bcce48fdda13d635d9b6f946c11abae35b (commit)
via e5e28035e44080acb1bf5369ad047d08c7bc9509 (commit)
via 9a5ad7ae3c0bb78eebdf18ede5521e2cd14f111c (commit)
from b180c31b29e81879138bf953da8cc7ca14aa7ab7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=cc9b3756aa71d453f413279a579f403b756ebd97
commit cc9b3756aa71d453f413279a579f403b756ebd97
Merge: 598630d f295225
Author: Arnold D. Robbins <address@hidden>
Date: Wed Oct 16 05:40:30 2013 +0300
Merge branch 'gawk-4.1-stable'
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=598630d323cad5d3acb69cfba3b296b18ccbecf1
commit 598630d323cad5d3acb69cfba3b296b18ccbecf1
Merge: a7fd49b 2c76d05
Author: Arnold D. Robbins <address@hidden>
Date: Wed Oct 16 05:37:09 2013 +0300
Merge branch 'gawk-4.1-stable'
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=a7fd49bcce48fdda13d635d9b6f946c11abae35b
commit a7fd49bcce48fdda13d635d9b6f946c11abae35b
Author: Arnold D. Robbins <address@hidden>
Date: Wed Oct 16 05:27:11 2013 +0300
Minor fix in do_rand().
diff --git a/ChangeLog b/ChangeLog
index ef1467b..fdd7738 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
* re.c (resetup): Add a comment about the joy of syntax bits.
+ Unrelated:
+
+ * builtin.c (do_rand): If result is exactly 1.0, keep trying.
+ Thanks to Nelson Beebe.
+
2013-10-10 Arnold D. Robbins <address@hidden>
* dfa.c (lex): Sync with GNU grep. Handle multibyte \s and \S.
diff --git a/builtin.c b/builtin.c
index 925a92b..740c88b 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2399,9 +2399,44 @@ do_rand(int nargs ATTRIBUTE_UNUSED)
* The add/subtract 0.5 keeps small bits from filling
* below 2^-53 in the double, not that anyone should be
* looking down there.
+ *
+ * Date: Wed, 25 Sep 2013 10:45:38 -0600 (MDT)
+ * From: "Nelson H. F. Beebe" <address@hidden>
+ * (4) The code is typical of many published fragments for converting
+ * from integer to floating-point, and I discuss the serious
pitfalls
+ * in my book, because it leads to platform-dependent behavior at
the
+ * end points of the interval [0,1]
+ *
+ * (5) the documentation in the gawk info node says
+ *
+ * `rand()'
+ * Return a random number. The values of `rand()' are uniformly
+ * distributed between zero and one. The value could be zero but
is
+ * never one.(1)
+ *
+ * The division by RAND_DIVISOR may not guarantee that 1.0 is never
+ * returned: the programmer forgot the platform-dependent issue of
+ * rounding.
+ *
+ * For points 4 and 5, the safe way is a loop:
+ *
+ * double
+ * rand(void) // return value in [0.0, 1.0)
+ * {
+ * value = internal_rand();
+ *
+ * while (value == 1.0)
+ * value = internal_rand();
+ *
+ * return (value);
+ * }
*/
tmprand = 0.5 + ( (random()/RAND_DIVISOR + random()) / RAND_DIVISOR);
+
+ while (tmprand == 1.0)
+ tmprand = 0.5 + ( (random()/RAND_DIVISOR + random()) /
RAND_DIVISOR);
+
return make_number((AWKNUM) (tmprand - 0.5));
}
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=e5e28035e44080acb1bf5369ad047d08c7bc9509
commit e5e28035e44080acb1bf5369ad047d08c7bc9509
Merge: b180c31 9a5ad7a
Author: Arnold D. Robbins <address@hidden>
Date: Wed Oct 16 05:10:48 2013 +0300
Merge branch 'gawk-4.1-stable'
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 9 +++++++++
builtin.c | 35 +++++++++++++++++++++++++++++++++++
configure | 3 ++-
m4/ChangeLog | 6 ++++++
m4/readline.m4 | 3 ++-
re.c | 7 +++++++
6 files changed, 61 insertions(+), 2 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-129-gcc9b375,
Arnold Robbins <=