lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Hmmm... So why does my programmers calculator, Go, _javascript_, etc, etc all return -3 in this case?
>
> Personally I think it's a bug, as "2" is not the correct result for that _expression_ (in any language but Lua it seems).

For what it's worth, among anyone who was a math major or took a course in algebra in college, the congruence class of -2 mod 5 is 3, and the idea that modulo should ever return negative numbers is an aberration inflicted on us by the makers of C some four decades ago. Just because everyone else timidly decided to follow in C's footsteps doesn't mean that this is the right thing to do, or even that it makes any sense at all.

Chris

On Wed, Jan 25, 2017 at 3:28 AM, Alex Silva <asandroq@gmail.com> wrote:
Hallo,

On 25/01/17 00:54, Milo Christiansen wrote:
>
> Wait, what am I saying, this is a language that thinks 1-based indexing
> is a good thing, forget I said anything. /s
>

Already forgotten.

--
-alex
http://unendli.ch/