[Issue 8672] New: %% operator

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 16 13:30:49 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8672

           Summary: %% operator
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-09-16 13:31:40 PDT ---
This proposal is an alternative to the Issue 7728

I suggest to add the operator %% that performs a modulus operation closer to
the mathematics definition, as defined in Python.

%% acts as % when both its arguments are unsigned or when they are both
positive signed numbers.

I think here a built-in operator is better than a Phobos function (as discussed
in Issue 7728): the built-in "%" operator is bug-prone, if you use it with
negative numbers. In theory both a Phobos function and a built-in operator are
usable to avoid such bugs. But I think having a built-in operator allows
programmers to better remember the problem with the standard % derived from C
and more often avoid its usage when numbers are negative, compared to a library
function.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list