How to test if an enum is inside a set

  • Thread starter Thread starter Alexander Muylaert
  • Start date Start date
if (MyTempVar = (++Counter++ == 5)) {
Counter += ++MyTempVar-- != 2;
}

I would also like to add that the C piece of code is *not* faster because it
is on 2 lines.

in pascal we would write it this way.

Inc(Counter);
MyTempVar := Ord(Counter = 5);
Inc(Counter);
if True then begin
Inc(MyTempVar);
Counter := Counter + Ord(MyTempVar <> 2);
Dec(Counter);
end;

Inc, Dec and Ord are *not* functions, it is compilermagic.

Compile both and check out the assembler. It is the same :-)

Amazing? And this even works on german and french computers ;-)

Kind regards

Alexander
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top