On Monday, 21 January 2019 at 15:01:27 UTC, Steven Schveighoffer wrote:

Probably, this optimizes into better code, but maybe the optimizer already does this with the expression above:

auto tmp = n % 3;
if(tmp < 0)
   tmp += 3;

It's just not a nice single expression.

-Steve

I don't think you can do this, imagine this case:

auto tmp = -1 % -3; // Note divisor in negative too.

tmp will be "-1" which already matches the Python way, so you can't add divisor anymore.

Matheus.

Reply via email to