Semantics of ExpressionType.Divide and ExpressionType.Modulo

Dec 27, 2008 at 4:31 AM
Edited Dec 30, 2008 at 6:45 PM
I have a question about the semantics of ExpressionType.Divide and ExpressionType.Modulo.

As far as I know, there are two major styles about "divide" and "modulo" for negative integers.

-10/3 -> -3
-10%2 -> -1

-10/3 -> -4
-10%2 -> 2

But Microsoft.Linq.Expressions.ExpressionType only has single Divide and Modulo. Above different styles may be entangled.
I think we must add another Divide and Module into the Microsoft.Linq.Expressions.ExpressionType (and System.Linq.Expressions.ExpressionType) like Add and AddChecked because the correct semantic mapping is important to exchange expression trees with various languages.

Are there any previous discussions or blog posts about this issue?

Edit 1:
I found some related design issues had been mentioned in expr-tree-spec.doc §2.3.1
Dec 30, 2008 at 3:19 PM
Edited Dec 30, 2008 at 3:19 PM

These expression types map directly onto the IL instructions“div” and “rem”, which have very well-defined semantics.  Languages which need different semantics simply need to build a slightly more complicated expression tree.

Dec 30, 2008 at 6:44 PM
I am releaved to hear that those expressions have very well-defined semantics.