What is faster, (a /= 2) or (a >>= 1)?
Variable a is an int. I suppose a >>= 1, but I want an answer which is not based on speculation.
this->getName() an answer without speculation cannot be given without more details as the performance of the code depends on the compiler (including patches, versions, switches etc.). As Vedant said, you have to try it to know exactly.
this->getName() I have a small advise for you....as we jump between different IDE the basic functionality remains same in the compiler and plus Mobiles are usually considered for their portability but let me say you .... please do not use Mobiles to make programs or test complex things, I know mobiles are more preferable but with portability you loose usability
Very likely bit shift, if there's any difference. But, you know, this simple thing only works on integer types and unless you really need to execute this statement *a lot* it's better to use the "/" as it expresses the intent in a way that everyone with miniscule C++ experience can understand.
@Kushagra >> is bitwise right shift operator.
But when the operations are always with a power of two, maybe the difference in time is significant. Or maybe the compiler knows that the divisor is a power of two and translates it into >>, so that the needed time is the same.
Your example is a corner case, as I insinuated in my original answer. Though it's irrelevant for "normal" application programming as division by two is not done very often in this domain but it's a neat trick that shows deeper understanding of number formats (great!) and might be very efficient (also great!) in corner cases.
try it yourself search for "time.h" header file on Google and set timers for both functions...take readings and then make conclusions...and yes be sure to post here the results
Time.h does not have such high precision timer. chrono yes, but I think it cannot be used with this app. Also, the time appeared in this app maybe changes from time to time, because internet connection is needed, i dont know.
these ">>" symbol are not use as, they are used in cout and cin .