CoffeScript adds a modulo operator %%

bearophile bearophileHUGS at lycos.com
Mon Feb 3 18:46:52 PST 2014


Asman01:

> Wouldn't be better if the current implementation just extends 
> to work with negatives instead of create a new one?

The % operator present in D works with negative numbers in a 
definite way, as in C99. But it has a semantics that in most 
cases is not the most useful one.

You can't change the semantics of the % D operator because of 
code breakage and breakage of compatibility with C99. But %% is 
one of the few ways to offer a new semantics.

For unsigned values or signed values that D knows statically have 
a positive value %% gets replaced by %.

Bye,
bearophile


More information about the Digitalmars-d mailing list