EXAPUNKS

EXAPUNKS

View Stats:
BUG: MODI and DIVI on negatives are inconsistent with each other
So, I'm aware the definition of integer division (and by consequence the MOD operation) when dealing with negative numbers is subject to interpretation, there's no official definition in mathematics[en.wikipedia.org], and computer languages differ on their interpretation[torstencurdt.com].

For example, `-13 % 3` yields -1 in C and Java but 2 (positive!) in Python and Ruby. The difference is justified by how they interpret integer division with negatives: In C, -13 / 3 = -4, as it truncates the result. Python uses the floor, so -13 // 3 = -5.

That's because all computer languages and also mathematics agree the following must hold true, even for negatives:
Number = Quotient * Divisor + Reminder => N = Q * D + R => R = N - Q * D => (N mod D) = N - (N div D) * D

What about ExaPunks? Well, it uses truncation for division, as in C, but floor for mod, as in Python!

DIVI -13 3 = -4 MODI -13 3 = +2

It should be either -4 and -1 or -5 and +2. This inconsistency breaks mathematics as R = N - Q*D does not apply in the game!
< >
Showing 1-6 of 6 comments
Bug? Or a feature!?
I must say, I don't fully understand when reading (but you might have an error in write-up, or I'm making an error reading)

You say:
In C/Java: Module = -1 and division = -4 (truncated).
In Python: Modulo = 2 and division = -5 (floor).

Then you quote the ExaPunks results. Which seem to be consistent with the Python way?

Basically, the -6 never comes up before your last paragraph.
Originally posted by thewifiwhisperer:
Bug? Or a feature!?

Jokes apart, Exapunks does not have to follow any known language, but it should have consistent mathematics: (N mod D) = N - (N div D) * D should always be true. I was bitten by this "feature" in at least 1 puzzle (the one you have to move a satellite dish motor to broadcast an encrypted movie)
Originally posted by thewifiwhisperer:
I must say, I don't fully understand when reading (but you might have an error in write-up, or I'm making an error reading)
...

Error is mine in the write-up when pasting values. I'll fix it now, thanks for pointing it out!
Makes sense now. Although I still do wonder if there's a way to exploit this for an advantage in one of the levels.
Originally posted by thewifiwhisperer:
Makes sense now. Although I still do wonder if there's a way to exploit this for an advantage in one of the levels.

I doubt it. It pretty much limits MODI usage to positive numbers only, as it does not agree with DIVI on negatives.
< >
Showing 1-6 of 6 comments
Per page: 1530 50