Not an expert in C ++ in any way, but in C # by doing this:
var a = new Func<float, float, double>((float f1, float f2) => (f1 + f2) * 0.5);
var b = new Func<float, float, double>((float f1, float f2) => (f1 + f2) / 2);
generates IL, which in the first:
- Loads Arguments
- Adds them (creates one)
- Converts the result to double
- Loads a double argument (0.5)
- Multiplies (creates double)
- Returns result
and the last
- Loads Arguments
- Adds them (creates one)
- Loads a constant integer (2)
- Divides ( , single/integer )
, , , , 2 , , , ( ).
:
Console.Out.WriteLine(((double)1) * ((double)1/3));
Console.Out.WriteLine((1) / ((float)3));
:
0.333333333333333
0.3333333
, "", , , .