Solving the double precision issue for string representations of 0d and -.1d : I have a numeric up/down control, essentially a normal textbox with up down buttons next to it that stores its value as a double. I have been running into an issue when cycling up and down, when the value is (or should be) 0 or -.1, the text box displays "1.38777878078145E-16" and "-0.0999999999999999" respectively.

I get that the floating point precision of double means that values get truncated and absolute precision for decimals longer than the doubles precision are lost. But seeing as how .1 does not have a long decimal or need high precision, shouldn't .1 - .1 = 0?

Right now I am just catching the string in my double to string converter and handling it, but is there a better way to do this?

No I cannot use decimal due to its overhead.

    [ValueConversion(typeof(Double), typeof(String))]
    public class DoubleToStringValueConverter : IValueConverter
    {
        public object Convert(object value,
                              Type targetType,
                              object parameter,
                              System.Globalization.CultureInfo culture)
        {
            string res = ((double)value).ToString(culture);
            if (res == "1.38777878078145E-16") res = "0";
            if (res == "-0.0999999999999999") res = "-1";
            return res;
        }

        public object ConvertBack(object value,
                                  Type targetType,
                                  object parameter,
                                  System.Globalization.CultureInfo culture)
        {
            string val = value as string;
            double res = 0d;
            double.TryParse(val, System.Globalization.NumberStyles.Float, culture, out res);
            return res;
        }

    }