+ 7
#include<stdio.h> int main() { printf("%x", -1<<1); getchar(); return 0; }
9 Réponses
+ 7
Who Do Better IT Ask the search bar.
+ 7
Please could some one help me out with logs/codes/ procedures of how to make animations in C/C++😊
+ 4
Arithmetic left shift ¹: shifting `-1` in two's complement ² representation to left by one as
-1 << 1
At binary level (32-bit words) we have:
1 =
0000 0000 0000 0000 0000 0000 0000 0001
-1 =
1111 1111 1111 1111 1111 1111 1111 1111
and by doing
1111 1111 1111 1111 1111 1111 1111 1111 << 1
we get
1111 1111 1111 1111 1111 1111 1111 1110 = -2 in decimal
And "%x" specifier would nicely format the hexadecimal representation of the above bit sequence [converts an unsigned integer into hexadecimal representation hhhh. ³]. Every 4 bits comprise one hex digit. So the total hex numbers are 8 as
fffffffe or FFFFFFFE (for "%X")
_____
¹ https://en.wikipedia.org/wiki/Arithmetic_shift
² https://en.wikipedia.org/wiki/Two%27s_complement
³ https://en.cppreference.com/w/cpp/io/c/fprintf
+ 3
Jamie💐 sorry
+ 3
This is the most confusing post I have ever seen.
+ 1
Tell me how I make a game in c++
+ 1
You have to learn very much if you want to make game and it also take much time depend on quality and world.
+ 1
fffffffe