Skip to main content
39 votes

Why does MATLAB have left division/solve?

Non-commutativity of multiplication a/b calculates $a \cdot b^{-1}$, whereas b\a calculates $b^{-1} \cdot a$. Since matrix ...
xigoi's user avatar
  • 1,007
10 votes

Why does MATLAB have left division/solve?

Solving linear systems is better than inverting The main reason is the one in xigoi's answer, noncommutativity, but let me add that a separate operator is handy to have for matrix operations: ...
Federico Poloni's user avatar
10 votes

Distinguishing modulo (Euclidean division) from remainder

There are two great articles investigating this question: Division and Modulus for Computer Scientists by Daan Leijen The Euclidean Definition of the Functions div and mod by Raymond Boute In short, ...
Jules's user avatar
  • 201
10 votes
Accepted

Distinguishing modulo (Euclidean division) from remainder

Given the usefulness of a proper modulo operator to wrap an integer into a range [0, n) e.g. for an array index or generating a random integer in this range, I find ...
kaya3's user avatar
  • 19.7k
8 votes

Ways to have operators for both normal and floor division

Julia's approach to this is to use รท for floor division (with div as an ascii alias)
Oscar Smith's user avatar
8 votes

Ways to have operators for both normal and floor division

Some options that don't involve namespaces: Python: a // b Visual Basic: a \ b Pascal: ...
user23013's user avatar
  • 2,510
5 votes
Accepted

Why is truncated or non-Euclidean division/modulo the norm?

The answer is largely given at the top of the answer by Jules to the question you linked: In short, div-mod operations come in pairs satisfying the equation ...
IMSoP's user avatar
  • 2,428
5 votes

Distinguishing modulo (Euclidean division) from remainder

One could always take the route of C's pairs of "and" and "or" operators -- call one % and the other %%.
Bbrk24's user avatar
  • 9,067
4 votes
Accepted

Ways to have operators for both normal and floor division

You can expand the operator to be more than a single character. For example you could do /int~ and /float~ to disambiguate which ...
ratchet freak's user avatar
4 votes

Ways to have operators for both normal and floor division

The Verse language has an interesting approach to this problem, where division of integers returns a value of type rational, further use of which demands explicit ...
abel1502's user avatar
  • 2,527
3 votes

Ways to have operators for both normal and floor division

Scoped configuration The interesting thing of having various divisions is that the code tends to use only one per compilation unit or function. Instead of creating a lot of cruft uncommon operators, ...
André L F S Bacci's user avatar
3 votes

Distinguishing modulo (Euclidean division) from remainder

I support Bbrk24's answer, but to add on; whether you use % or %% for Euclidean modulo, you should consider what the target ...
SectorCorruptor's user avatar
1 vote

Why does MATLAB have left division/solve?

Overloading I'm not familiar with MATLAB/Octave, but this could be used for operator overloading in custom classes (if that's supported in MATLAB/Octave). Simplifying syntax If you have something like ...
The Thonnu's user avatar
  • 1,518

Only top scored, non community-wiki answers of a minimum length are eligible