I am having some trouble with a rounding issue. I have a converter to update a graphs scale to the nearest 10, based on what value comes in. the value can be either positive or negative.
I have attempted to build a math statement to round to the nearest 10 however with exceptionally small numbers it doesn't work. (numbers under 5).
the value that comes in is a double, but will be displayed in an int. any help with seeing what I did wrong would be great.
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (int)((double)value >= 0 ?
(Math.Round((double)value / 10, MidpointRounding.AwayFromZero) * 10) :
(Math.Abs((Math.Round((double)value / 10, MidpointRounding.AwayFromZero) * 10)) * -1));
}