1 votes 1 votes Suppose we have a 32-bit memory and we have to represent unsigned int a = -5 What will the memory representation look like? 000000…….1011 or 111…..1011 tusharb asked Mar 1, 2022 tusharb 414 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply lalitver10 commented Mar 2, 2022 reply Follow Share @tusharhigh Answer:-- 111…..1011 Explaination: It does not matter wheater we are storing negative integer or positive integer it alway’s follows 2’s complement system .In case of positive value (+5) it directly stores it’s value in its binary format ie: 00 ….0000101 But in case of negative integer (-5) it stores in 2’complement form (111….101). The role of datatype signed or unsigned comes into the picture when we are trying to access it.if we are using unsigned int value which is stored in memory will directly get converted in decimal format but in case of signed datatype value first converted in normal form and then it used. 1 votes 1 votes tusharb commented Mar 2, 2022 reply Follow Share Thanks man, great explanation 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes it will be like 1111...1011 you can check it yourself, just run this- unsigned int i = -5; printf(“%x”,i); or https://onlinegdb.com/XC_KvJWdjG shishir__roy answered Mar 1, 2022 selected Mar 2, 2022 by tusharb shishir__roy comment Share Follow See 1 comment See all 1 1 comment reply shishir__roy commented Mar 1, 2022 reply Follow Share https://stackoverflow.com/questions/50605/signed-to-unsigned-conversion-in-c-is-it-always-safe 1 votes 1 votes Please log in or register to add a comment.