/// <summary> /// Scales a value by (max - min), then divides it by scale and adds it to min /// </summary> /// <param name="scale">An optional scale value for integer types (default 1)</param> public static T FractionToValue <T> (T fraction, T min, T max, T?scale = null) where T : struct { var range = OperatorCache <T> .Subtract(max, min); var global = OperatorCache <T> .Multiply(fraction, range); if (scale != null) { global = OperatorCache <T> .Divide(global, scale.Value); } return(OperatorCache <T> .Add(min, global)); }
public static T Add <T>(T x, T y) { return(OperatorCache <T> .Add(x, y)); }