Hello,
i am just curious, i want to know if we have a bool like X, and if we want to check if it is 0, which if statement is more efficient This->if(!X)
or This->if(x^1)
.(i checked the asm code and the codes were not the same so i think they defer from one another.)
Thanks.
can someone give me any reason for the down-votes?
did i write something wrong??
Or everyone in cf is in a bad mood?
I can explain downvotes.
This is something completely unimportant. Differences between them will be very small.
You can easily check it by yourself.
You don't need to know assembly to make run-time tests.
run-time tests are useless for this situation.
converting to asm may help because assembly op codes i think have specific run times on specific hardware.
Dafuq? You want to test EFFICIENCY and that is exactly what run-time tests will show x_0.
i tested with a for to 10^6 and the outcome was same for me.....(But opcodes in asm DIFFER!)
There are 2 variable x, y. One little funny thing about variables is that they can have the same value (x = 4 and y = 4 for example).
Yes, x and y are different variables, but it doesn't mean that they can't hold the same value.
It's the same thing with opcodes. Different opcodes doesn't have to mean different running times. It's perfectly normal.
Yes x, y can have the same value BUT when it comes to efficiency, it matters how MANY times you use X and you use Y.
when i use cat on my asm, there are 2 movl's and one subl and 2 function calls for X^1 and 1 movl and 3 function calls for !X.
nvm, seems this conversation is going no-where, i have to sleep. Goodnight.
If you think that way, trying to understand it from assembly code is also useless because assembly code is compiler-dependent.
i know thats why i need someone that is familiar with "GAS"(gnu assembler).
shervin, you know assembly. Don't lie to others ;)
i dont know GAS functions.:P(really, it matters a lot)
Goodnight
Goodnight my friend ;)
I'm not sure about efficiency, but I would definitely go with the first one since it's much more readable, and it doesn't really matter because difference -if there is any- would be negligible.