Should % ever "overflow"?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 25 20:54:28 PDT 2016


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 ?


More information about the Digitalmars-d mailing list