+ 1

Can i use >> or << operators in any other way except cin &cout ?

as i can understand >> and << are operator just like - + * so why can't we use them in the same line , like b=(cin>> a)+3; i mean we can do this cout << a+ b ; ,,, and what other ways can we use them ,,,,

27th Jan 2017, 9:51 AM
Mina Ghaly
Mina Ghaly - avatar
2 odpowiedzi
0
<< and >> are bitwise operators. Generally, as a programmer you don't need to concern yourself about operations at the bit level. You're free to think in bytes, or ints and doubles, or even higher level data types composed of a combination of these. But there are times when you'd like to be able to go to the level of an individual bit. Exclusive-or encryption is one example when you need bitwise operations. Another example comes up when dealing with data compression: what if you wanted to compress a file? In principle, this means taking one representation and turning it into a representation that takes less space. One way of doing this is to use an encoding that takes less than 8 bits to store a byte. (For instance, if you knew that you would only be using the 26 letters of the Roman alphabet and didn't care about capitalization, you'd only need 5 bits to do it.) In order to encode and decode files compressed in this manner, you need to actually extract data at the bit level. Finally, you can use bit operations to speed up your program or perform neat tricks. (This isn't always the best thing to do.) Read more about it here http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/
27th Jan 2017, 9:58 AM
Alex
Alex - avatar
0
Called bitwise operation, you can to store or define values on pow of 2. i.e #include <iostream> using namespace std; int main() { for ( int i = 0; i < 10; i++ ){ double bitwise = 1 << i; std::cout << bitwise << std::endl ; } return 0; } Maybe this way are confuse: 1 << 5, mean move 5 position to left, 10000x = 2**5
27th Jan 2017, 10:50 AM
nextco
nextco - avatar