What is the real difference between u suffix and unsigned modifier?

Here I tried using both of them:

unsigned short foo1 = 65535;
short foo2 = 65535u;
cout << foo1 << endl << foo2 << endl;

And the output was:

65535
-1

What is the u suffix really used for? And for example if I replace 65535 with 65534 I'd get -2 as an output instead of -1. Meanwhile unsigned does what it's supposed to do.



from Recent Questions - Stack Overflow https://ift.tt/3mR7S5h
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)