Try the following:
(long)387420489 * (long)9
Dynamic Expresso has a web shell here where you can test the expressions;
http://dynamic-expresso.azurewebsites.net/
While testing on this web shell, I realized that;
387420489L * 9 => Syntax error (at index 9). => does not accept type suffix
(long)387420489 * 9 => -808182895 => overflow
387420489 * (long)9 => 3486784401 => OK
2147483647 + 1 => -2147483648 => int.MaxValue + 1 = int.MinValue (overflow)
2147483648 + 1 => 2147483649 => When does not fit into Int32, interpreted as long
While most of these can be regarded as by design (considering how Dynamic Expresso evaluates the statement), there can still be further improvement.
Think of Javascript for example.
387420489*9 => 3486784401
The question is, is what we need
- to execute the given arithmetic expression correctly, as we and the end-user expects,
- to execute the given arithmetic expression the C# way?
The former, I think.