diff options
author | john haque <j.eh@mchsi.com> | 2012-04-11 21:11:26 -0500 |
---|---|---|
committer | john haque <j.eh@mchsi.com> | 2012-04-11 21:11:26 -0500 |
commit | b99af9ec0835ba702bcf3e62fa36dd76876dc354 (patch) | |
tree | aeaa28b8b8d8be7e30e0ae5ff48f8305f0b868f3 | |
parent | 9bc37b0ee389c9a8be843b9f30d11bb7df899c20 (diff) | |
download | egawk-b99af9ec0835ba702bcf3e62fa36dd76876dc354.tar.gz egawk-b99af9ec0835ba702bcf3e62fa36dd76876dc354.tar.bz2 egawk-b99af9ec0835ba702bcf3e62fa36dd76876dc354.zip |
Change RNDMODE to ROUNDMODE and update doc.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | FUTURES | 2 | ||||
-rw-r--r-- | README_d/ChangeLog | 3 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | awk.h | 4 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/awkcard.in | 2 | ||||
-rw-r--r-- | doc/gawk.1 | 2 | ||||
-rw-r--r-- | doc/gawk.texi | 22 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | mpfr.c | 11 | ||||
-rw-r--r-- | test/dumpvars.ok | 2 | ||||
-rw-r--r-- | test/mpfrrnd.awk | 16 |
13 files changed, 50 insertions, 33 deletions
@@ -1,3 +1,7 @@ +2012-04-11 John Haque <j.eh@mchsi.com> + + * main.c (varinit): Change RNDMODE to ROUNDMODE. + 2012-04-11 Arnold D. Robbins <arnold@skeeve.com> * main.c: Change --arbitrary-precision to --bignum. @@ -22,7 +22,7 @@ For 4.1 Merge xmlgawk XML extensions - Integrate MPFR to provide high precision arithmetic. + DONE: Integrate MPFR to provide high precision arithmetic. Continue code reviews / code cleanup diff --git a/README_d/ChangeLog b/README_d/ChangeLog index 5424385c..e319a9ce 100644 --- a/README_d/ChangeLog +++ b/README_d/ChangeLog @@ -1,3 +1,6 @@ +2012-04-11 John Haque <j.eh@mchsi.com> + README.hacking: New file. + 2012-04-01 John Haque <j.eh@mchsi.com> README.mpfr: New file. @@ -11,6 +11,8 @@ Really make failure to open a socket a non-fatal error (for 4.1). ?? Scope IDs for IPv6 addresses ?? +Merge the chapter and the appendix on floating-point math (for 4.1). + ------ Code Review: @@ -1018,7 +1018,7 @@ extern NODE *FNR_node, *FS_node, *IGNORECASE_node, *NF_node; extern NODE *NR_node, *OFMT_node, *OFS_node, *ORS_node, *RLENGTH_node; extern NODE *RSTART_node, *RS_node, *RT_node, *SUBSEP_node, *PROCINFO_node; extern NODE *LINT_node, *ERRNO_node, *TEXTDOMAIN_node, *FPAT_node; -extern NODE *PREC_node, *RNDMODE_node; +extern NODE *PREC_node, *ROUNDMODE_node; extern NODE *Nnull_string; extern NODE *Null_field; extern NODE **fields_arr; @@ -1546,7 +1546,7 @@ extern long getenv_long(const char *name); /* mpfr.c */ extern void set_PREC(void); -extern void set_RNDMODE(void); +extern void set_ROUNDMODE(void); #ifdef HAVE_MPFR extern int mpg_cmp(const NODE *, const NODE *); extern int format_ieee(mpfr_ptr, int); diff --git a/doc/ChangeLog b/doc/ChangeLog index 2ae1fb96..a54832db 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2012-04-11 John Haque <j.eh@mchsi.com> + + * gawk.texi: Change RNDMODE to ROUNDMODE. + * gawk.1, awkcard.in: Ditto. + 2012-04-11 Arnold D. Robbins <arnold@skeeve.com> * gawk.texi: Change --arbitrary-precision to --bignum. diff --git a/doc/awkcard.in b/doc/awkcard.in index ef15a8ca..ab42e9fd 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -625,7 +625,7 @@ T} Length of the string matched by \*(FCmatch()\*(FR; \-1 if no match. T} -\*(CB\*(FCRNDMODE\fP T{ +\*(CB\*(FCROUNDMODE\fP T{ The rounding mode to use for arbitrary precision arithmetic, by default \*(FC"N"\fP.\*(CD T} @@ -1174,7 +1174,7 @@ the version of .IR gawk . .RE .TP -.B RNDMODE +.B ROUNDMODE The rounding mode to use for arbitrary precision arithmetic on numbers, by default \fB"N"\fR (IEEE-754 roundTiesToEven mode). The accepted values are diff --git a/doc/gawk.texi b/doc/gawk.texi index d49ac9c1..44243b36 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -12635,8 +12635,8 @@ character. (@xref{Output Separators}.) The working precision of arbitrary precision floating-point numbers, 53 by default (@pxref{Setting Precision}). -@cindex @code{RNDMODE} variable -@item RNDMODE # +@cindex @code{ROUNDMODE} variable +@item ROUNDMODE # The rounding mode to use for arbitrary precision arithmetic on numbers, by default @code{"N"} (@samp{roundTiesToEven} in the IEEE-754 standard) @@ -18670,7 +18670,7 @@ The @dfn{rounding mode} specifies the behavior for the results of numerical operations when discarding extra precision. Each rounding mode indicates how the least significant returned digit of a rounded result is to be calculated. -The @code{RNDMODE} variable (@pxref{Setting Rounding Mode}) provides +The @code{ROUNDMODE} variable (@pxref{Setting Rounding Mode}) provides program level control over the rounding mode. @ref{table-rounding-modes} lists the IEEE-754 defined rounding modes: @@ -18678,7 +18678,7 @@ rounding modes: @float Table,table-rounding-modes @caption{Rounding Modes} @multitable @columnfractions .45 .30 .25 -@headitem Rounding Mode @tab IEEE Name @tab @code{RNDMODE} +@headitem Rounding Mode @tab IEEE Name @tab @code{ROUNDMODE} @item Round to nearest, ties to even @tab @code{roundTiesToEven} @tab @code{"N"} or @code{"n"} @item Round toward plus Infinity @tab @code{roundTowardPositive} @tab @code{"U"} or @code{"u"} @item Round toward negative Infinity @tab @code{roundTowardNegative} @tab @code{"D"} or @code{"d"} @@ -18771,14 +18771,14 @@ results to any desired precision level supported by MPFR. Two built-in variables @code{PREC} (@pxref{Setting Precision}) -and @code{RNDMODE} +and @code{ROUNDMODE} (@pxref{Setting Rounding Mode}) provide control over the working precision and the rounding mode. The precision and the rounding mode are set globally for every operation to follow. The default working precision for arbitrary precision floats is 53, -and the default value for @code{RNDMODE} is @code{"N"}, +and the default value for @code{ROUNDMODE} is @code{"N"}, which selects the IEEE-754 @samp{roundTiesToEven} (@pxref{Rounding Mode}) rounding mode.@footnote{The default precision is 53, since according to the MPFR documentation, @@ -18885,24 +18885,24 @@ issues that occur because numbers are stored internally in binary. @node Setting Rounding Mode @section Setting the Rounding Mode -@cindex @code{RNDMODE} variable +@cindex @code{ROUNDMODE} variable -The built-in variable @code{RNDMODE} has the default value @code{"N"}, +The built-in variable @code{ROUNDMODE} has the default value @code{"N"}, which selects the IEEE-754 rounding mode @samp{roundTiesToEven}. -The other possible values for @code{RNDMODE} are @code{"U"} for rounding mode +The other possible values for @code{ROUNDMODE} are @code{"U"} for rounding mode @samp{roundTowardPositive}, @code{"D"} for @samp{roundTowardNegative}, and @code{"Z"} for @samp{roundTowardZero}. @command{gawk} also accepts @code{"A"} to select the IEEE-754 mode @samp{roundTiesToAway} if your version of the MPFR library supports it; otherwise setting -@code{RNDMODE} to this value has no effect. @xref{Rounding Mode}, +@code{ROUNDMODE} to this value has no effect. @xref{Rounding Mode}, for the meanings of the various rounding modes. Here is an example of how to change the default rounding behavior of @code{printf}'s output: @example -$ @kbd{gawk -M -vRNDMODE="Z" 'BEGIN @{ printf("%.2f\n", 1.378) @}'} +$ @kbd{gawk -M -vROUNDMODE="Z" 'BEGIN @{ printf("%.2f\n", 1.378) @}'} @print{} 1.37 @end example @@ -36,7 +36,7 @@ #define DEFAULT_PROFILE "awkprof.out" /* where to put profile */ #define DEFAULT_VARFILE "awkvars.out" /* where to put vars */ #define DEFAULT_PREC 53 -#define DEFAULT_RNDMODE "N" /* round to nearest */ +#define DEFAULT_ROUNDMODE "N" /* round to nearest */ static const char *varfile = DEFAULT_VARFILE; const char *command_file = NULL; /* debugger commands */ @@ -68,7 +68,7 @@ NODE *ENVIRON_node, *ERRNO_node, *FIELDWIDTHS_node, *FILENAME_node; NODE *FNR_node, *FPAT_node, *FS_node, *IGNORECASE_node, *LINT_node; NODE *NF_node, *NR_node, *OFMT_node, *OFS_node, *ORS_node, *PROCINFO_node; NODE *RLENGTH_node, *RSTART_node, *RS_node, *RT_node, *SUBSEP_node; -NODE *PREC_node, *RNDMODE_node; +NODE *PREC_node, *ROUNDMODE_node; NODE *TEXTDOMAIN_node; NODE *_r; /* used as temporary in stack macros */ @@ -572,7 +572,7 @@ out: #ifdef HAVE_MPFR /* Set up MPFR defaults, and register pre-exec hook to process arithmetic opcodes */ if (do_mpfr) - init_mpfr(DEFAULT_PREC, DEFAULT_RNDMODE); + init_mpfr(DEFAULT_PREC, DEFAULT_ROUNDMODE); #endif /* load group set */ @@ -965,7 +965,7 @@ static const struct varinit varinit[] = { {&ORS_node, "ORS", "\n", 0, NULL, set_ORS, TRUE, 0 }, {NULL, "PROCINFO", NULL, 0, NULL, NULL, FALSE, NO_INSTALL | NON_STANDARD }, {&RLENGTH_node, "RLENGTH", NULL, 0, NULL, NULL, FALSE, 0 }, -{&RNDMODE_node, "RNDMODE", DEFAULT_RNDMODE, 0, NULL, set_RNDMODE, FALSE, NON_STANDARD }, +{&ROUNDMODE_node, "ROUNDMODE", DEFAULT_ROUNDMODE, 0, NULL, set_ROUNDMODE, FALSE, NON_STANDARD }, {&RS_node, "RS", "\n", 0, NULL, set_RS, TRUE, 0 }, {&RSTART_node, "RSTART", NULL, 0, NULL, NULL, FALSE, 0 }, {&RT_node, "RT", "", 0, NULL, NULL, FALSE, NON_STANDARD }, @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-2012 the Free Software Foundation, Inc. + * Copyright (C) 2012 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -600,15 +600,18 @@ get_rnd_mode(const char rmode) return -1; } -/* set_RNDMODE --- update MPFR rounding mode related variables when RNDMODE assigned to */ +/* + * set_ROUNDMODE --- update MPFR rounding mode related variables + * when ROUNDMODE assigned to + */ void -set_RNDMODE() +set_ROUNDMODE() { if (do_mpfr) { mpfr_rnd_t rndm = -1; NODE *n; - n = force_string(RNDMODE_node->var_value); + n = force_string(ROUNDMODE_node->var_value); if (n->stlen == 1) rndm = get_rnd_mode(n->stptr[0]); if (rndm != -1) { diff --git a/test/dumpvars.ok b/test/dumpvars.ok index 68c6a7bb..73d3d306 100644 --- a/test/dumpvars.ok +++ b/test/dumpvars.ok @@ -18,7 +18,7 @@ OFS: " " ORS: "\n" PREC: 53 RLENGTH: 0 -RNDMODE: "N" +ROUNDMODE: "N" RS: "\n" RSTART: 0 RT: "\n" diff --git a/test/mpfrrnd.awk b/test/mpfrrnd.awk index eafefb9f..508ac26b 100644 --- a/test/mpfrrnd.awk +++ b/test/mpfrrnd.awk @@ -3,13 +3,13 @@ BEGIN { printf(" %.15f\n", N) printf("* %.10f\n", N) # default - RNDMODE="N"; printf("N %.10f\n", N) - RNDMODE="U"; printf("U %.10f\n", N) - RNDMODE="D"; printf("D %.10f\n", N) - RNDMODE="Z"; printf("Z %.10f\n", N) + ROUNDMODE="N"; printf("N %.10f\n", N) + ROUNDMODE="U"; printf("U %.10f\n", N) + ROUNDMODE="D"; printf("D %.10f\n", N) + ROUNDMODE="Z"; printf("Z %.10f\n", N) N = -N - RNDMODE="N"; printf("N %.10f\n", N) - RNDMODE="U"; printf("U %.10f\n", N) - RNDMODE="D"; printf("D %.10f\n", N) - RNDMODE="Z"; printf("Z %.10f\n", N) + ROUNDMODE="N"; printf("N %.10f\n", N) + ROUNDMODE="U"; printf("U %.10f\n", N) + ROUNDMODE="D"; printf("D %.10f\n", N) + ROUNDMODE="Z"; printf("Z %.10f\n", N) } |