Skip to content
Prev 180376 / 398503 Next

specify the number of decimal numbers

On 14-May-09 15:15:16, James W. MacDonald wrote:
This happens also when you use C's fprintf and sprintf (at any rate
in my gcc):

  #include <stdio.h>
  #include <math.h>
  main(argc,argv) int argc; char **argv;
  {
  fprintf(stdout, "%.1f\n", 0.15);
  fprintf(stdout, "%.1f\n", 0.05);
  fprintf(stdout, "%.2f\n", 0.15);
  fprintf(stdout, "%.2f\n", 0.05);
  }

  cc -o testprint3 testprint3.c
  ./testprint
  0.1
  0.1
  0.15
  0.05

(with similar output when printing a string formatted by sprintf).

So, in so far a R relies on the compiler's implementation of the
*printf functions, this can hardly be put right withbout re-writing
[g]cc!

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 14-May-09                                       Time: 17:16:40
------------------------------ XFMail ------------------------------