[Rd] [Repost 3/3] Minor glitch in 'Writing R Extensions'

Dirk Eddelbuettel edd at debian.org
Sat Sep 15 20:37:21 CEST 2012


[ Email repost 3 of 3 ]

  From: Dirk Eddelbuettel <edd at debian.org>
  To: R-devel org <r-devel at r-project.org>
  Subject: [Patch] Minor glitch in 'Writing R Extensions'
  Date: Mon, 3 Sep 2012 10:58:32 -0500
  
  
  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  

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



More information about the R-devel mailing list