+/**
+ * This function takes a value of the form "2.000E-03" and returns the index
+ * of an array where a matching pair was found.
+ *
+ * @param value The string to be parsed.
+ * @param array The array of s/f pairs.
+ * @param array_len The number of pairs in the array.
+ * @param result The index at which a matching pair was found.
+ *
+ * @return SR_ERR on any parsing error, SR_OK otherwise.
+ */
+static int array_float_get(gchar *value, const uint64_t array[][2],
+ int array_len, unsigned int *result)
+{
+ struct sr_rational rval;
+ struct sr_rational aval;
+
+ if (sr_parse_rational(value, &rval) != SR_OK)
+ return SR_ERR;
+
+ for (int i = 0; i < array_len; i++) {
+ sr_rational_set(&aval, array[i][0], array[i][1]);
+ if (sr_rational_eq(&rval, &aval)) {
+ *result = i;
+ return SR_OK;
+ }
+ }
+
+ return SR_ERR;
+}
+