mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Improvements to %g pull request
This code %g is preliminary. Fixed some code style issues to match the current code style. Added regression tests and help file updates to printf and strprintf. Fixed use of magic number -4: using -P instead. Noted two problem areas with XXX comments in qio.c: 1) need a qprintfg function 2) re-write to not modify conf->outdigits
This commit is contained in:
44
help/printf
44
help/printf
@@ -28,7 +28,7 @@ DESCRIPTION
|
||||
zero or more decimal digits
|
||||
an optional '. followed by zero or more decimal deigits
|
||||
an optional 'l'
|
||||
one of the letters: d, s, c, f, e, r, o, x, b,
|
||||
one of the letters: d, s, c, f, e, g, r, o, x, b,
|
||||
|
||||
If any other character is read, the '%' and any characters
|
||||
between '%' and the character are ignored and no specifier is
|
||||
@@ -51,26 +51,27 @@ DESCRIPTION
|
||||
d, s, c current config("mode")
|
||||
f real (decimal, floating point)
|
||||
e exponential
|
||||
g real or exponential depending on config("display")
|
||||
r fractional
|
||||
o octal
|
||||
x hexadecimal
|
||||
b binary
|
||||
|
||||
If the number of arguments after fmt is less than the
|
||||
number of format specifiers in fmt, the "missing" arguments
|
||||
may be taken to be null values - these contribute nothing to the
|
||||
output; if a positive width w has been specified, the effect is
|
||||
to produce w spaces, e.g. printf("abc%6dxyz") prints "abc xyz".
|
||||
If the number of arguments after fmt is less than the number
|
||||
of format specifiers in fmt, the "missing" arguments may be
|
||||
taken to be null values - these contribute nothing to the output;
|
||||
if a positive width w has been specified, the effect is to
|
||||
produce w spaces, e.g., printf("abc%6dxyz") prints "abc xyz".
|
||||
|
||||
If i <= the number of specifiers in fmt, the value of argument x_i
|
||||
is printed in the format specified by the i-th specifier.
|
||||
If a positive width w has been specified and normal printing of x_i
|
||||
does not include a '\n' character, what is printed will if necessary
|
||||
be padded with spaces so that the length of the printed output
|
||||
is at least the w. Note that control
|
||||
characters like '\t', '\b' each count as one character. If
|
||||
the 'right-pad' flag has been set, the padding is on the right;
|
||||
otherwise it is on the left.
|
||||
If i <= the number of specifiers in fmt, the value of argument
|
||||
x_i is printed in the format specified by the i-th specifier.
|
||||
If a positive width w has been specified and normal printing
|
||||
of x_i does not include a '\n' character, what is printed will
|
||||
if necessary be padded with spaces so that the length of the
|
||||
printed output is at least the w. Note that control characters
|
||||
like '\t', '\b' each count as one character. If the 'right-pad'
|
||||
flag has been set, the padding is on the right; otherwise it
|
||||
is on the left.
|
||||
|
||||
If i > the number of specifiers in fmt, the value of argument x_i
|
||||
does not contribute to the printing. However, as all arguments
|
||||
@@ -84,9 +85,9 @@ DESCRIPTION
|
||||
mode.
|
||||
|
||||
In the case of floating-point (f) format the precision determines
|
||||
the maximum number of decimal places to be
|
||||
displayed. Other aspects of this printing may be affected by the
|
||||
configuration parameters "outround", "tilde", "fullzero", "leadzero".
|
||||
the maximum number of decimal places to be displayed. Other
|
||||
aspects of this printing may be affected by the configuration
|
||||
parameters "outround", "tilde", "fullzero", "leadzero".
|
||||
|
||||
EXAMPLE
|
||||
; c = config("epsilon", 1e-6); c = config("display", 6);
|
||||
@@ -116,6 +117,11 @@ EXAMPLE
|
||||
[2] = "undefined"
|
||||
[3] = NULL
|
||||
|
||||
; c = config("display", 50);
|
||||
; printf("%g %g\n%g %g\n", 1e5, 1e49, 1e50, 1e500);
|
||||
100000 100000000000000000000000000000000000000000000000000
|
||||
1e50 1e500
|
||||
|
||||
|
||||
LIMITS
|
||||
The number of arguments of printf() is not to exceed 1024.
|
||||
@@ -126,7 +132,7 @@ LINK LIBRARY
|
||||
SEE ALSO
|
||||
fprintf, strprintf, print
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
## Copyright (C) 1999-2006,2018 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -27,6 +27,13 @@ EXAMPLE
|
||||
"1.732051, 1.732051,1.732051 , ~1.7320,~1.7320,~1.
|
||||
"
|
||||
|
||||
; c = config("display", 50);
|
||||
; fmt2 = "%g %g\n%g %g\n"
|
||||
; strprintf(fmt2, 1e5, 1e49, 1e50, 1e500);
|
||||
"100000 100000000000000000000000000000000000000000000000000
|
||||
1e50 1e500
|
||||
"
|
||||
|
||||
LIMITS
|
||||
The number of arguments of strprintf() is not to exceed 1024.
|
||||
|
||||
@@ -39,7 +46,7 @@ SEE ALSO
|
||||
|
||||
printf, fprintf, print
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
## Copyright (C) 1999-2006,2018 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
Reference in New Issue
Block a user