The system will treat negative numbers in 2's complement method.Example:Assume the size of int is 2-bytes(16 bits). The integer value 1 is represented as given below: Binary of 1: 00000000 00000001 (this is for positive value of 1)1's complement of binary 1: 11111111 111111102's complement of binary 1: 11111111 11111111Thy system will store '11111111 11111111' in memory to represent '-1'. If we do left shift (3 bits) on 11111111 11111111 it will become as given below:11111111 11111111 ---(left shift 3 times)---> 11111111 11111000. So, 11111111 11111000 ---(binary to hex)---> FF F8. (Required Answer) Note: How is the negative number obtained from 2's complement value?As stated above, -1 is represented as '11111111 11111111' in memory.So, the system will take 2's complement of '11111111 11111111' to the get the original negative value back. Example: Bit Representation of -1: 11111111 11111111Since the left most bit is 1, it is a negative number. Then the value is1's complement: 00000000 000000002's complement: 00000000 00000001 (Add 1 to the above result) Therefore, '00000000 00000001' = 1 and the sign is negative.Hence the value is -1.
C
Topic: Operators
Assuming a integer 2-bytes, What will be the output of the program?
#include<stdio.h>
int main(){
printf("%xn", -1<<3);
return 0;
}
Browse random answers:
What is the use of ?: operator?
What is the condition that is applied with ?: operator?
What are bitwise shift operators?
Explain the use of bit fieild.
Which operator is known as dummy operator in c?
Which bitwise operator is suitable for checking whether a particular bit is ON or OFF?Bitwise AND operator.
How to swap two numbers using bitwise operators?
When should a type cast not be used?
Can math operations be performed on a void pointer?
In which numbering system can the binary number 1011011111000101 be easily converted to?
Assuming a integer 2-bytes, What will be the output of the program? #include<stdio.h> int main(){ printf("%xn", -1<<3); return 0; }
Write Addition of two numbers using Bitwise operators?
What is the use of Bitwise operators? what is the use of unformatted Input/Output functions?
Which bit wise operator is suitable for checking whether a particular bit is on or off ?
How to swap two numbers using bitwise operators? Program: #include <stdio.h> int main() { int i = 65; int k = 120; printf("n value of i=%d k=%d before swapping", i, k); i = i ^ k; k = i ^ k; i = i ^ k; printf("n value of i=%d k=%d after swapping", i, k); return 0;}
How I can add two numbers in c language without using Arithmetic operators?
How to convert decimal to octal and hexadecimal & binary using shift registers?
Which bit wise operator is suitable for turning off a particular bit in a number ?
What is conversion operator?
Write a C program, the given number is double, without using addition and multiplication operator?
What is the diff between "new" and "operator new" ?
What is a modulus operator? What are the restrictions of a modulus operator?
How can i find size of a variable without using sizeof() operator?
Why don't we add null pointer at the end of array of integer?How can we calculate the length of array of integer?
What is Operator overloading ?
How will you print % character?
Which of the following are NOT relational operators ?
Why Preincrement operator is faster than Postincrement?
Write Addition of two numbers using Bitwise operators.?
What is pointers and its uses?
When is a switch statement better than multiple if statements?