summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-28 20:55:53 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-28 20:55:53 -0800
commitffada96ffdf3dae7c1932deebd6f512ede5f2aa5 (patch)
tree08b9fa969e686e01d1456a7e1bdb7407cf9094b5 /txr.1
parentd6eca506a08d569d4c821c724242fc556638342c (diff)
downloadtxr-ffada96ffdf3dae7c1932deebd6f512ede5f2aa5.tar.gz
txr-ffada96ffdf3dae7c1932deebd6f512ede5f2aa5.tar.bz2
txr-ffada96ffdf3dae7c1932deebd6f512ede5f2aa5.zip
New variables for floating-point printing control.
* lib.c (obj_print_impl): Instead of hard-coded "~s", obtain the format string for floats from the *print-flo-format* special variable, whose default value is "~s". * stream.c (print_flo_digits_s, print_flo_format_s): New symbol variables. (formatv): Use *print-flo-digits* value for default precision for ~f and ~e, rather than hard-coded 3. (stream_init): Initialize print_flo_digits_s and print_flo_format_s, and register special variables under those symbols. * stream.h (print_flo_digits_s, print_flo_format_s): Declared. * txr.1: Documented new specials.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.184
1 files changed, 70 insertions, 14 deletions
diff --git a/txr.1 b/txr.1
index af09e88b..0458ebd7 100644
--- a/txr.1
+++ b/txr.1
@@ -32016,12 +32016,13 @@ the
.code /dev/null
device on Unix, but does not involve the operating system.
-.coNP Special variable @ *print-flo-precision*
+.coNP Special variable @ *print-flo-format*
.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
+.code *print-flo-format*
+variable determines the conversion format which is applied when
+a floating-point value is converted to decimal text by the
+functions
.codn print ,
.cond pprint ,
.cond prinl ,
@@ -32029,15 +32030,48 @@ floating-point values are converted to decimal text by the functions
.code tostring
and
.codn tostringp .
-It also applies when the
+
+The default value is
+.codn "~s" .
+
+The format string must specify the consumption of exactly one argument.
+
+The conversion string may use embedded width and precision values:
+for instance,
+.code "~3,4f"
+is a valid value for
+.codn *print-flo-format* .
+
+.coNP Special variable @ *print-flo-precision*
+.desc
+The
+.code *print-flo-precision*
+special variable specifies the default floating-point printing
+precision which is used when the
.code ~a
-and
+or
.code ~s
-conversion specifiers of the
+conversion specifier of the
.code format
-function are used for printing a floating-point value, and no precision
+function is used for printing a floating-point value, and no precision
is specified.
+Note that since the default value of the variable
+.code *print-flo-format*
+is the string
+.codn "~s" ,
+the
+.code *printf-flo-precision*
+variable, by default, also determines 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 .
+
The default value of
.code *print-flo-precision*
is that of the
@@ -32052,6 +32086,23 @@ to the value of the
.code flo-max-dig
variable.
+.coNP Special variable @ *print-flo-digits*
+.desc
+The
+.code *print-flo-precision*
+special variable specifies the default floating-point printing
+precision which is used when the
+.code ~f
+or
+.code ~e
+conversion specifier of the
+.code format
+function is used for printing a floating-point value, and no precision
+is specified.
+
+Its default value is
+.codn 3 .
+
.coNP Special variable @ *print-base*
.desc
The
@@ -32393,10 +32444,13 @@ it does not allow an argument of character type).
The precision specifier gives the number of digits past the decimal point.
The number is rounded off to the specified precision, if necessary.
Furthermore, that many digits are always printed, regardless of the actual
-precision of the number or its type. If it is omitted, then the default value
-is three: three digits past the decimal point. A precision of zero means no
-digits pas the decimal point, and in this case the decimal point is suppressed
-(regardless of whether the numeric argument is floating-point or integer).
+precision of the number or its type. If it is omitted, then the value
+is obtained from the special variable
+.codn *print-flo-digits* ,
+whose default value is three: three digits past the decimal point. A precision
+of zero means no digits pas the decimal point, and in this case the decimal
+point is suppressed (regardless of whether the numeric argument is
+floating-point or integer).
.coIP e
The
@@ -32412,8 +32466,10 @@ The precision specifier gives the number of digits past the decimal point
printed in the exponential notation, not counting the digits in the exponent.
Exactly that many digits are printed, regardless of the precision of the
number. If the precision is omitted, then the number of digits after the
-decimal point is three. If the precision is zero, then a decimal portion is
-truncated off entirely, including the decimal point.
+decimal point is obtained from the value of the special variable
+.codn *print-flo-digits* ,
+whose default value is three. If the precision is zero, then a decimal portion
+is truncated off entirely, including the decimal point.
.coIP p
The