FAQ
The (marked up in info mode) manual Writing R Extensions says in 6.1.3

-- Function: double fprec (double X, double DIGITS)
Returns the value of X rounded to DIGITS decimal digits (after the
decimal point).

This is the function used by R's `round()'.
^^^^^^^^^^

-- Function: double fround (double X, double DIGITS)
Returns the value of X rounded to DIGITS _significant_ decimal
digits.

This is the function used by R's `signif()'.
^^^^^^^^^^^

I think that is crossed vis-a-vis the the corresponding R functions, ie

'double fprec is used by 'signif (not round)

'double fround' is used by 'round' (not signif)

as I just found out by trying to unit-test wrappers just added to Rcpp.

Sources seem to agree -- src/main/arithmetic.c has

case 10001: return Math2(args, fround);/* round(), src/nmath/fround.c */
case 10004: return Math2(args, fprec); /* signif(), src/nmath/fprec.c */

So with that I suggest to alter the R-exts.texi as the patch below does.

Hope this helps, Dirk


edd at max:/tmp$ diff -u R-exts.texi.orig R-exts.texi
--- R-exts.texi.orig 2012-09-03 10:56:21.219528679 -0500
+++ R-exts.texi 2012-09-03 10:56:42.359529056 -0500
@@ -10659,14 +10659,14 @@
Returns the value of @var{x} rounded to @var{digits} decimal digits
(after the decimal point).

-This is the function used by @R{}'s @code{round()}.
+This is the function used by @R{}'s @code{signif()}.
@end deftypefun

@deftypefun double fround (double @var{x}, double @var{digits})
Returns the value of @var{x} rounded to @var{digits} @emph{significant}
decimal digits.

-This is the function used by @R{}'s @code{signif()}.
+This is the function used by @R{}'s @code{round()}.
@end deftypefun

@deftypefun double ftrunc (double @var{x})
edd at max:/tmp$



--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-devel @
categoriesr
postedSep 3, '12 at 3:58p
activeSep 3, '12 at 3:58p
posts1
users1
websiter-project.org
irc#r

1 user in discussion

Dirk Eddelbuettel: 1 post

People

Translate

site design / logo © 2022 Grokbase