这是C代码吗:
/* LERP(a,b,c) = linear interpolation macro, is 'a' when c == 0.0 and 'b' when c == 1.0 */
#define LERP(a,b,c) (((b) - (a)) * (c) + (a))
http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_T.html
等于此 C# 代码?
private static double LERP(double a, double b, double c) { return (((b) - (a)) * (c) + (a)); }
?
最佳答案
没有。 考虑以下几点:
LERP(x++,1,2);
C 代码也可能有增加 x 两次的副作用[@phresnel 提到它是未定义的],而 c# 代码是完美定义的,并且只会增加 x 一次。
结果也可能不同,因为第一个 a
和第二个 [在宏中] 可能有不同的值,因为它可能在第一个中增加了。
关于c# - #定义从C到C#的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7229865/