[Rd] WRE about R_strtod

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Tue Oct 8 09:16:52 CEST 2024


Hello,

This is what "Writing R extensions" currently says about R_atof and
R_strtod:

>> Function: void R_atof (const char* str)
>> Function: void R_strtod (const char* str, char ** end)
>>
>> Implementations of the C99/POSIX functions atof and strtod which
>> guarantee platform-dependent behaviour, including always using the
>> period as the decimal point aka ‘radix character’ and converting
>> "NA" to R’s NA_REAL_ . 

Besides the easily fixable return type (void -> double), shouldn't the
documentation mention the fact that, unlike the standard C library
functions, R's parser returns NA_REAL instead of 0 when no conversion
is performed (including for the "NA" string, *end == str)?

Index: doc/manual/R-exts.texi
===================================================================
--- doc/manual/R-exts.texi	(revision 87211)
+++ doc/manual/R-exts.texi	(working copy)
@@ -16482,12 +16482,12 @@
 
 @apifun R_atof
 @apifun R_strtod
- using deftypefun void R_atof (const char* @var{str})
- using deftypefunx void R_strtod (const char* @var{str}, char ** @var{end})
+ using deftypefun double R_atof (const char* @var{str})
+ using deftypefunx double R_strtod (const char* @var{str}, char ** @var{end})
 Implementations of the C99/POSIX functions @code{atof} and @code{strtod}
 which guarantee platform-dependent behaviour, including always using the
-period as the decimal point @emph{aka} `@I{radix character}' and converting
- using code{"NA"} to R's @code{NA_REAL_} .
+period as the decimal point @emph{aka} `@I{radix character}' and returning
+R's @code{NA_REAL_} for all unconverted strings, including @code{"NA"}.
 @end deftypefun
 

-- 
Best regards,
Ivan



More information about the R-devel mailing list