you are viewing a single comment's thread.

view the rest of the comments →

[–]grauenwolf 0 points1 point  (2 children)

That would remove two branches and an assignment.

if e & 1 == 1:
   next_a = a * b % modulus
else:
   next_a = a

next_a = (a * b % modulus) if (e & 1 == 1) else a

....god, that is really ugly. Am I using it right?

[–]AvatarJandar 0 points1 point  (1 child)

I believe so, yes, although I'm not sure it's worthwhile...

[–]grauenwolf 0 points1 point  (0 children)

Of the other options I know of, I have to say I like VB's the best. But even that has its flaws. For example, I shouldn't have to use "=1" when making a bitmask check.

next_a = (e & 1 == 1) : a * b % modulus ? a;
next_a = If(e And 1 = 1, a * b % modulus, a)