From Kurt@Horn|k @end|ng |rom wu@@c@@t  Thu Oct 10 11:04:26 2024
From: Kurt@Horn|k @end|ng |rom wu@@c@@t (Kurt Hornik)
Date: Thu, 10 Oct 2024 11:04:26 +0200
Subject: [Rd] WRE about R_strtod
In-Reply-To: <20241008101618.6acf739c@Tarkus>
References: <20241008101618.6acf739c@Tarkus>
Message-ID: <26375.39066.926653.673190@hornik.net>

>>>>> Ivan Krylov via R-devel writes:

Thanks: changed now.

Best
-k

> 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
> - at deftypefun void R_atof (const char* @var{str})
> - at deftypefunx void R_strtod (const char* @var{str}, char ** @var{end})
> + at deftypefun double R_atof (const char* @var{str})
> + at 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
> - at 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

> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] WRE about R_strtod
Kurt Hornik