The majority of my users write scripts to implement custom mathematical functionality. It is very common for my users to write expressions with integer literals and assume the math will be floating-point. For example
double f(double x)
{
return x**(2/3) + x**2 + 1;
}
instead of
double f(double x)
{
return x**(2.0/3.0) + x**2 + 1;
}
Most don’t have any idea what integer division is. Those with any programming background tend to have experience with Visual Basic or Matlab, both of which always use floating-point division. I find myself correcting this common mistake frequently, and I only expect it to get worse as my user base grows.
I hesitate to ask, because it would be a departure from C++ behavior, but could AngelScript adopt an Engine Behavior option that would treat the / and /= operators as floating-point division? We could introduce \ and \= operators to perform integer division (like Visual Basic and Python 3). I suppose even with the engine option disabled the \ and \= operators could still be of some use.
a \ b; // int(a) / int(b)
Let me know what you think, and let me know if you have any alternative suggestions. This is a very common mistake that my users make, so I need to do something about it. Of course, if you agree to the Engine Behavior option, I would provide the implementation.
Thank you for your consideration,
Jason