How the Negative Numbers are Stored in Memory? Last Updated : 26 Aug, 2025 Comments Improve Suggest changes Like Article Like Report Prerequisite - Base conversions1’s and 2’s complement of a binary number2’s complement of a binary stringSuppose the following fragment of code, int a = -34; Now how will this be stored in memory. So here is the complete theory. Whenever a number with minus sign is encountered, the number (ignoring minus sign) is converted to its binary equivalent. Then the two’s complement of the number is calculated. That two’s complement is kept at place allocated in memory and the sign bit will be set to 1 because the binary being kept is of a negative number. Whenever it comes on accessing that value firstly the sign bit will be checked if the sign bit is 1 then the binary will be two’s complemented and converted to equivalent decimal number and will be represented with a minus sign. Let us take an example: Example - int a = -2056; Binary of 2056 will be calculated which is: 00000000000000000000100000001000 (32 bit representation, according of storage of int in C) 2’s complement of the above binary is: 11111111111111111111011111111000. So finally the above binary will be stored at memory allocated for variable a. When it comes on accessing the value of variable a, the above binary will be retrieved from the memory location, then its sign bit that is the left most bit will be checked as it is 1 so the binary number is of a negative number so it will be 2’s complemented and when it will be 2’s complemented will be get the binary of 2056 which is: 00000000000000000000100000001000 The above binary number will be converted to its decimal equivalent which is 2056 and as the sign bit was 1 so the decimal number which is being gained from the binary number will be represented with a minus sign. In our case -2056.A Comment More infoAdvertise with us M MohitPandey1 Follow Improve Article Tags : Computer Science Fundamentals Explore Basics of ComputerComputer Hardware10 min readWhat is a Computer Software?8 min readCentral Processing Unit (CPU)6 min readInput and Output Devices12 min readComputer Memory9 min readApplication SoftwareMS Word Tutorial - Learn How to Use Microsoft Word7 min readMS Excel Tutorial - Learn Excel Online Free11 min readMS PowerPoint Tutorial: Basic to Advanced5 min readSystem SoftwareWhat is an Operating System?5 min readWindows 10 Tutorial15+ min readLinux/Unix Tutorial10 min readTop 10 iOS App Development Tools That You Can Consider7 min readWhat is macOS?4 min readNetworks & Internet ProtocolsBasics of Computer Networking10 min readIntroduction to Internet10 min readWeb Protocols9 min readWeb Server and Its Types8 min readProgramming LanguagesC Programming Language Tutorial4 min readPython Tutorial - Learn Python Programming Language6 min readJava Tutorial6 min readJavaScript Tutorial8 min read Like