as the title says i wanna now how numbers are stored and i searched google ofcourse and i didnt find any thing
i tried this code(C++ code):
#include <iostream>
#include <bitset>
int main ()
{
int a = -2;
std::bitset<8> x(a);
std::cout << x << '\n';
int c = 2;
std::bitset<8> y(c);
std::cout << y << '\n';
return 0;
}
it outputs:
11111110
00000010
i know how binary works like from the first digit from the right if it is 1 it is 1 second is 2 third is 4 and … but for the – i dont get it can anyone explain this simply?
note: i found some other questions like this but none had good answers or explanation