summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-11-13 20:36:46 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-11-13 20:36:46 -0800
commit9f633256dea9a141bc5a4d96b2b9c47e3ecb4858 (patch)
treee2b375d7384323b9abeb55a8af10edec08b3a101 /txr.1
parentb8cfcb2280d63ac9ebf92a001f87c2b3fe4e204b (diff)
downloadtxr-9f633256dea9a141bc5a4d96b2b9c47e3ecb4858.tar.gz
txr-9f633256dea9a141bc5a4d96b2b9c47e3ecb4858.tar.bz2
txr-9f633256dea9a141bc5a4d96b2b9c47e3ecb4858.zip
New global control over float print precision.
* configure (have_dbl_decimal_dig): New variable. New configure test to test for DBL_DECIMAL_DIG or __DBL_DECIMAL_DIG__, resulting in FLO_MAX_DIG macro being deposited in config.h. * arith.c (arith_init): Register flo-max-dig variable. * stream.c (print_flo_precision_s): New symbol variable. (formatv): Obtain default precision from *print-flo-precision* special variable, rather than hard coded DBL_DIG. (stream_init): Initialize print_flo_precision_s variable, and register *print-flo-precision* special. * txr.1: Document flo-max-dig, *print-flo-precision*, and change of behavior in format.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.157
1 files changed, 52 insertions, 5 deletions
diff --git a/txr.1 b/txr.1
index f608b558..79fa9520 100644
--- a/txr.1
+++ b/txr.1
@@ -26385,6 +26385,15 @@ to a \*(TX floating-point number, and back to decimal, without a change in any o
the digits. This holds regardless of the value of the number, provided that it
does not exceed the floating-point range.
+.coNP Variable @ flo-max-dig
+.desc
+This variable holds an integer representing the maximum number of
+decimal digits required to capture the value of a floating-point number
+such that the resulting decimal form will convert back to the same
+floating-point number. See also the
+.code *print-flo-precision*
+variable.
+
.coNP Variables @ %pi% and @ %e%
.desc
These variables hold an approximation of the mathematical constants \(*p and e.
@@ -30753,6 +30762,42 @@ the
.code /dev/null
device on Unix, but does not involve the operating system.
+.coNP Special variable @ *print-flo-precision*
+.desc
+The
+.code *print-flo-precision*
+special variable holds the precision which applies when
+floating-point values are converted to decimal text by the functions
+.codn print ,
+.cond pprint ,
+.cond prinl ,
+.cond pprinl ,
+.code tostring
+and
+.codn tostringp .
+It also applies when the
+.code ~a
+and
+.code ~s
+conversion specifiers of the
+.code format
+function are used for printing a floating-point value, and no precision
+is specified.
+
+The default value of
+.code *print-flo-precision*
+is that of the
+.code flo-dig
+variable.
+
+Note: to print floating-point values in such a way that their values
+can be precisely recovered from the printed representation, it is
+recommended to override
+.code *print-flo-precision*
+to the value of the
+.code flo-max-dig
+variable.
+
.coNP Function @ format
.synb
.mets (format < stream-designator < format-string << format-arg *)
@@ -30974,11 +31019,13 @@ When this specifier is used for floating-point values, the precision specifies
the maximum number of total significant figures, which do not include any
digits in the exponent, if one is printed. Numbers are printed in exponential
notation if their magnitude is small, or else if their exponent exceeds their
-precision. (If the precision is not specified, then it defaults to the
-system-dependent number of digits in a floating point value, derived from the C
-language
-.code DBL_DIG
-constant.) Floating point values which are integers are
+precision. If the precision is not specified, then it is obtained from
+the
+.code *print-flo-precision*
+special variable, whose default value is the same as that of the
+.code flo-dig
+variable.
+Floating point values which are integers are
printed without a trailing
.code .0
(point zero).