SR_PRIV int sr_atod_ascii(const char *str, double *ret);
SR_PRIV int sr_atod_ascii_digits(const char *str, double *ret, int *digits);
SR_PRIV int sr_atof_ascii(const char *str, float *ret);
+SR_PRIV int sr_atof_ascii_digits(const char *str, float *ret, int *digits);
SR_PRIV int sr_count_digits(const char *str, int *digits);
return SR_OK;
}
+/**
+ * Convert text to a floating point value, and get its precision.
+ *
+ * @param[in] str The input text to convert.
+ * @param[out] ret The conversion result, a double precision float number.
+ * @param[out] digits The number of significant decimals.
+ *
+ * @returns SR_OK in case of successful text to number conversion.
+ * @returns SR_ERR when conversion fails.
+ */
+SR_PRIV int sr_atof_ascii_digits(const char *str, float *ret, int *digits)
+{
+ int d;
+ float f;
+
+ if (sr_count_digits(str, &d) != SR_OK || sr_atof_ascii(str, &f) != SR_OK)
+ return SR_ERR;
+
+ if (ret)
+ *ret = f;
+
+ if (digits)
+ *digits = d;
+
+ return SR_OK;
+}
+
/**
* Get the precision of a floating point number.
*