Ok Simon, how about this one :
x = min( x , 100 );
or
if( x > 100 )x = 100;
And thank you Fir.
greetings
What about that one? What's the question?
Code clarity is almost the only thing that matters here, so use the one that most closely represents your intent.
For instance, if x is something that is computed in some way but we want to cap it from above for some reason, I would write
int capped_x = min(x, 100);
This is because it's easier to reason about the code if the meaning of a variable doesn't change through its lifetime, and if it has a descriptive name.
Do yourself a favor and stop thinking of micro-optimizations that won't make a difference.
I agree with that it is not important except of the tight processing
loops - but there maybe this is important but it leads to good level
of knowing assembly level code - the thing that i ew would like to
know and i would like to talk here with some asm knowing people
but maybe they are hard to find today (also in www world there seem
to be hard to find good and easy materials /tutorials today learning
how to hand optymize procedures in asm
as to opinions if this would result in general optymisations - some say no (and they belive compiler produce code better than you do) - some say yes (and they say that still compiler are silly to produce uneffective
code sometimes -
I tend to belive the later in some special cases and the first in other (maybe most) cases
- but in general i think it is worth it to be interested in this thing (depending of the thing if you want to 'waste' the time on trying
to speed up procedures or no