Lecture#11#12_CSE_1012(4)
Lecture#11#12_CSE_1012(4)
CSE-1010 :Programming I
Negative+negantive= positive
(-101)+(-27)=10011011+11100101=10000000 carry1
negative+negative=negative
Sum=-128 in decimal (2's complement). No overflow
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 7
Overflow can also be detected using 2 Bit
Comparator just by checking Carry-in(C-in)
and Carry-Out(C-out) from MSB’s.
In first Figure the MSB of two numbers are 0 which means they are positive.
Here if C-in is 1 we get answer’s MSB as 1 means answer is negative (Overflow) and C-out as 0.
C-in not equal C-out hence overflow.
In second Figure the MSB of two numbers are 1 which means they are negative.
Input Output
Here if C-in is 0 we get answer MSB as 0 means answer is positive(Overflow) and C-out as 1.
C-in not equal C-out hence overflow. A B A XOR B
Carry-in and Carry-out at MSB’s are enough to detect Overflow. 0 0 0
0 1 1
1 0 1
1 1 0
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 13
Refenceres
Online content
https://www.geeksforgeeks.org/overflow-in-arithmetic-addition-in-
binary-number-system/
• https://www.electronics-tutorials.ws/binary/signed-binary-
numbers.html
https://smartwebworker.com/ascii-codes/
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 20
21
CSE 1010 (Programming I) - MIIT
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 22
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 23
Extended Binary Coded Decimal
Interchange Code
• Extended binary coded decimal interchange code(EBCDIC)
• 8 bits character encoding techniques
• 28 supports 256 combination of different character
• Used on IBM mainframe operating system.
• EBCDIC is easier to use on punched cards.
• Similar to ASCII characters
• The two most common encoding schemes store Unicode text as sequences of
either 2 or 4 bytes. The official terms for these encodings are UCS-2 and UCS-4,
respectively.
• UCS stands for Universal Character Set as specified by ISO/IEC 10646.
• The number indicates the number of octets (an octet is 8 bits) in the coded
character set. UCS-2 indicates two octets, while UCS-4 indicates four octets.
• UTF stands for Unicode Transformation Format.
• In order to be compatible with older systems that didn't support Unicode,
Encoding Forms were defined by the Unicode Consortium to be a representation
of the character in bits.
• The number indicates the encoding form that is to be used: UTF-8 indicates an 8-
bit encoding form, while UTF-16 indicates a 16-bit encoding form.
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 28
References
Online Content
Images and Photos are credit to original uploader in Google
https://www.youtube.com/watch?v=B1Sf1IhA0j4
https://www.youtube.com/watch?v=-oYfv794R9s
https://www.youtube.com/watch?v=B1Sf1IhA0j4
• Subramanian, K. R. V., & Subramanian, U. , “ Introductory problem solving and
programming (using C). “Courseware prepared especially for Myanmar Institute
of Information Technology, Mandalay, 2017
• Reema Thareja, “Fundamentals Of Computers”, Oxford University Press, 2015
• Reema Thareja, “Introduction to C Programming”, Second Edition, Oxford
University Press, 2015
01/24/2025 MIIT, Mandalay, CSE-1010 Programming I 29
Learning to write programs stretches your mind, and helps you think
better, creates a way of thinking about things that I think is helpful in
all domains.”
—Bill Gates, Co-Chairman, Bill & Melinda Gates Foundation, Co-Founder, Microsoft