[R] printing reals from C with digits

Ott Toomet otoomet at econ.dk
Wed Jan 29 09:31:24 CET 2003


Hi,

I want to print real numbers in C code with different values for
digits.  How to do that?

As I have understood, what I should do is to call

StringFromReal()

which calls FormatReal(), that one suggests the parameters (width,
decimal places and exponential form).  FormatReal() includes

    eps = pow(10.0, -(double)R_print.digits);

So I guess I have to change the value of R_print.digits.
R_print.digits is defined in include/Print.h in the package source,
but unfortunately the installed version (in /usr/lib/R/include/R_ext) is
quite a different.  I guess that is because the structure is not meant
to be accessible by user, although some system routines alter
R_print.digits directly.

So are there any good way to achieve it?


This R 1.5.0 on an RH 6.2 computer if that matters.

Thanks for help.

Ott




More information about the R-help mailing list