SR_PRIV GVariant *std_gvar_min_max_step_thresholds(const double min, const double max, const double step)
{
- double d;
+ double d, v;
GVariant *gvar, *range[2];
GVariantBuilder gvb;
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
for (d = min; d <= max; d += step) {
- range[0] = g_variant_new_double(d);
- range[1] = g_variant_new_double(d);
+ /*
+ * We will never see exactly 0.0 because of the error we're
+ * accumulating, so catch the "zero" value and force it to be 0.
+ */
+ v = ((d > (-step / 2)) && (d < (step / 2))) ? 0 : d;
+
+ range[0] = g_variant_new_double(v);
+ range[1] = g_variant_new_double(v);
gvar = g_variant_new_tuple(range, 2);
g_variant_builder_add_value(&gvb, gvar);