Ok, I'm not used to thinking in terms of %f & %g but your explanation makes sense.
To clarify, the '#' shouldn't be there, right?
PS
Sent from my iPad
On Jul 26, 2017, at 5:38 PM, Allin Cottrell <cottrell(a)wfu.edu>
wrote:
> On Wed, 26 Jul 2017, Summers, Peter wrote:
>
> Hi all,
>
> I've come across a typo on p. 80 in the user's guide. In discussing how to
access elements of an array, there's the following example:
>
> <verbatim>
> # for M an array of matrices
> printf "\n%#12.5\n", M[1]
> </verbatim>
>
> The second line should be
> printf "\n%12.5f\n", M[1]
Thanks, Peter. There was a typo, but actually what we had in mind in this case was
printf "\n%#12.5g\n", M[1]
The conversion 'g' for floating-point numbers means "use scientific notation
if necessary" (i.e. for very big or very small numbers), and the '#' modifier
means, print any trailing zeros to the given precision.
With 'g', the "precision" value (here 5) refers to significant digits
rather than decimal places. So it's a better choice than 'f' for numbers that
might, for all the code-writer knows, be very big or small.
Allin
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
https://linkprotect.cudasvc.com/url?a=http://lists.wfu.edu/mailman/listin...