Should % ever "overflow"?

Smoke Adams via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 25 21:25:07 PDT 2016


On Sunday, 26 June 2016 at 03:54:28 UTC, deadalnix wrote:
> On Sunday, 26 June 2016 at 02:05:53 UTC, "Smoke" Adams wrote:
>> On Sunday, 26 June 2016 at 00:31:29 UTC, deadalnix wrote:
>>> On Saturday, 25 June 2016 at 23:01:00 UTC, "Smoke" Adams 
>>> wrote:
>>>> This proves nothing.
>>>>
>>>
>>> This isn't a proof, this is a definition. This is the 
>>> definition that is used by all programming languages out 
>>> there and all CPUs. It isn't going to change because someone 
>>> on the internet think he has a better definition that provide 
>>> no clear advantage over the current one.
>>
>> Again, no proof at all
>
> Either can't read or you can't think. Which is it ?
>
>> and inaccurate. Not every programming language or cpu does 
>> this. Please don't make up facts to support your "definitions" 
>> and desires. Having a negative modulo is just ignorant.
>
> Languages:
> C#: https://msdn.microsoft.com/en-us/library/0w4e0fzs.aspx
> Java: 
> https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17.3
> C11: 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/C99RationaleV5.10.pdf (See 6.5.5 for update on % operator, mentioning, example at 7.20.6).
> Python2: https://docs.python.org/2/reference/expressions.html
> Python3: https://docs.python.org/3/reference/expressions.html
>
> CPUs:
> Arm7(eeabi): 
> https://github.com/wayling/xboot-clone/blob/master/src/arch/arm/lib/gcc/__aeabi_idivmod.S
> Arm7(Darwin): 
> http://opensource.apple.com//source/clang/clang-163.7.1/src/projects/compiler-rt/lib/arm/modsi3.S
> Mips: 
> http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html 
> (See DIV instruction)
> X86: http://x86.renejeschke.de/html/file_module_x86_id_137.html
>
> Now I'm sure there are a weird CPU that isn't produced since 
> the 80s and that D will never support that do it in some other 
> way, but for all platforms that matter today, this isn't the 
> case.
>
> This is not MY definition, this is the definition everybody 
> except you uses? Even PHP get this right 
> (http://php.net/manual/en/language.operators.arithmetic.php).
>
> Now champion, what do you have supporting your definition ?

Your a moron. I guess you think just because everyone believes in 
Santa Clause it means he exists?

http://mathworld.wolfram.com/Congruence.html
https://en.wikipedia.org/wiki/Modulo_operation
https://en.wikipedia.org/wiki/Modular_arithmetic
http://stackoverflow.com/questions/1082917/mod-of-negative-number-is-melting-my-brain
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=6422581
http://www.mathworks.com/help/matlab/ref/mod.html?requestedDomain=www.mathworks.com

It's one thing to claim that the sign of the modulo is the same 
as the sign of the divisor, but entirely different to claim the 
modulo should be negative.

Of course, I don't expect a neanderthal like yourself to 
understand that. Have fun lemming.

Oh, hey, I'm going to define that your an idiot! Thanks for 
agreeing with me.



More information about the Digitalmars-d mailing list