X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fanalog.c;h=8d87302afbfc9ee090943ca0331437e7ed8306ec;hb=0bcdeb90c4d689a8d51797c266c76946619f482e;hp=e4521689a11d5ca1338087e1667480aab424c000;hpb=22fb1bffc33b47f575c4b1c967b5051ddb505c5c;p=libsigrok.git diff --git a/src/analog.c b/src/analog.c index e4521689..8d87302a 100644 --- a/src/analog.c +++ b/src/analog.c @@ -220,44 +220,6 @@ SR_API int sr_analog_to_float(const struct sr_datafeed_analog *analog, return SR_OK; } -/** - * Convert a floating point value to a string, limited to the given - * number of decimal digits. - * - * @param[in] value The value to convert. - * @param[in] digits Number of digits after the decimal point to print. - * Must be >= 0. - * @param[out] result Pointer to store result. Must not be NULL. - * - * The string is allocated by the function and must be freed by the caller - * after use by calling g_free(). - * - * @retval SR_OK Success. - * @retval SR_ERR_ARG Invalid argument. - * - * @since 0.4.0 - */ -SR_API int sr_analog_float_to_string(float value, unsigned int digits, char **result) -{ - unsigned int cnt, i; - - if (!result) - return SR_ERR_ARG; - - /* This produces at least one too many digits. */ - *result = g_strdup_printf("%.*f", digits, value); - for (i = 0, cnt = 0; (*result)[i]; i++) { - if (isdigit((*result)[i++])) - cnt++; - if (cnt == digits) { - (*result)[i] = 0; - break; - } - } - - return SR_OK; -} - /** * Convert the unit/MQ/MQ flags in the analog struct to a string. *