You are on page 1of 6

21st February: Lecture#16: 3rd Slot

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Convert negative decimal to binary number
• How you convert a negative decimal number to a binary number is probably quite
unlike other numerical conversions you have performed because your mind.

• However, it is a straightforward process.

• The conversion is done using a two's complement binary, which requires the
programmer to instruct the computer to interpret any binary number starting with 1
as negative.

• The program then constructs the corresponding positive number in binary, takes its
complement and adds one.

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Convert negative decimal to binary number
• Example,
• For −47 the computer would create the binary number for +47:
• 47= 0001 1111
• The complement of this is:
• 1110 0000
• Adding one to this gives:
• 1110 0001 = -47

• Note that the computer has "signed" these numbers to treat a leading 1 as negative
and process the results differently than simply adding up the powers of 2 occupied
by the symbol 1.

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Write an 8051 c program to find +ve and –ve number among five byte if array. Send
+ve data to P1 and –ve to P2.

• How to detect positive and negative numbers?


• MSB of positive number is 0 and MSB of negative number is 1.
• So, if we AND any number with 80h 
• it will result in 00h if number is positive
• Or, it will result in 80h if the number is negative.

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Write an 8051 c program to find +ve and –ve number among five byte if array. Send
+ve data to P1 and –ve to P2

By, Nirav Joshi 6th Electrical, Summer 2023


Thank
You
Find me on:
Nirav Joshi
nirav.joshi@marwadieducation.edu.in
9909350982

You might also like