NUMBER SYSTEM CONVERSIONS, Lecture notes of Architecture

Therefore, through a two-step conversion process, octal 345 equals binary 011100101 equals hexadecimal E5. 3. OCTAL TO DECIMAL. The conversion can also be ...

Typology: Lecture notes

2021/2022

Uploaded on 08/05/2022

aichlinn
aichlinn 🇮🇪

4.4

(46)

1.9K documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NUMBER SYSTEM
Number systems are the technique to represent numbers in the computer system architecture,
every value that you are saving or getting into/from computer memory has a defined number
system.
Computer architecture supports following number systems.
Binary number system
Octal number system
Decimal number system
Hexadecimal (hex) number system
BINARY NUMBER SYSTEM
A Binary number system has only two digits that are 0 and 1. Every number (value) represents
with 0 and 1 in this number system. The base of binary number system is 2, because it has only
two digits.
OCTAL NUMBER SYSTEM
Octal number system has only eight (8) digits from 0 to 7. Every number (value) represents with
0,1,2,3,4,5,6 and 7 in this number system. The base of octal number system is 8, because it has
only 8 digits.
DECIMAL NUMBER SYSTEM
Decimal number system has only ten (10) digits from 0 to 9. Every number (value) represents
with 0,1,2,3,4,5,6, 7,8 and 9 in this number system. The base of decimal number system is 10,
because it has only 10 digits.
HEXADECIMAL NUMBER SYSTEM
A Hexadecimal number system has sixteen (16) alphanumeric values from 0 to 9 and A to F.
Every number (value) represents with 0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E and F in this number
system. The base of hexadecimal number system is 16, because it has 16 alphanumeric values.
Here A is 10, B is 11, C is 12, D is 14, E is 15 and F is 16.
Number system
Base(Radix)
Used digits
Example
Binary
2
0,1
(11110000)2
Octal
8
0,1,2,3,4,5,6,7
(360)8
Decimal
10
0,1,2,3,4,5,6,7,8,9
(240)10
Hexadecimal
16
0,1,2,3,4,5,6,7,8,9,
A,B,C,D,E,F
(F0)16
CONVERSIONS
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download NUMBER SYSTEM CONVERSIONS and more Lecture notes Architecture in PDF only on Docsity!

NUMBER SYSTEM

Number systems are the technique to represent numbers in the computer system architecture, every value that you are saving or getting into/from computer memory has a defined number system.

Computer architecture supports following number systems.

Binary number systemOctal number systemDecimal number systemHexadecimal (hex) number system

BINARY NUMBER SYSTEM

A Binary number system has only two digits that are 0 and 1. Every number (value) represents with 0 and 1 in this number system. The base of binary number system is 2, because it has only two digits.

OCTAL NUMBER SYSTEM

Octal number system has only eight (8) digits from 0 to 7. Every number (value) represents with 0,1,2,3,4,5,6 and 7 in this number system. The base of octal number system is 8, because it has only 8 digits.

DECIMAL NUMBER SYSTEM

Decimal number system has only ten (10) digits from 0 to 9. Every number (value) represents with 0,1,2,3,4,5,6, 7,8 and 9 in this number system. The base of decimal number system is 10, because it has only 10 digits.

HEXADECIMAL NUMBER SYSTEM

A Hexadecimal number system has sixteen (16) alphanumeric values from 0 to 9 and A to F. Every number (value) represents with 0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E and F in this number system. The base of hexadecimal number system is 16, because it has 16 alphanumeric values. Here A is 10, B is 11, C is 12, D is 14, E is 15 and F is 16.

Number system Base(Radix) Used digits Example

Binary 2 0,1 (11110000) 2

Octal 8 0,1,2,3,4,5,6,7 (360) 8

Decimal 10 0,1,2,3,4,5,6,7,8,9 (240) 10

Hexadecimal 16

A,B,C,D,E,F

(F0) 16

CONVERSIONS

DECIMAL TO OTHER

1. DECIMAL TO BINARY

Decimal Number System to Other Base

To convert Number system from Decimal Number System to Any Other Base is quite easy; you have to follow just two steps: A) Divide the Number (Decimal Number) by the base of target base system (in which you want to convert the number: Binary (2), octal (8) and Hexadecimal (16)). B) Write the remainder from step 1 as a Least Signification Bit (LSB) to Step last as a Most Significant Bit (MSB).

Decimal to Binary Conversion Result

Decimal Number is : (12345) 10

Binary Number is (11000000111001) 2

2. DECIMAL TO OCTAL

Decimal to Octal Conversion Result

Decimal Number is : (12345) 10

Octal Number is (30071) 8

3. DECIMAL TO HEXADECIMAL

Octal: 0 1 2 3 4 5 6 7

Binary = 011 100 101

Octal = 3 4 5 = 345 oct

3. BINARY TO HEXADECIMAL

An equally easy way to convert from binary to hexadecimal is to group binary digits into sets of four, starting with the least significant (rightmost) digits.

Binary: 11100101 = 1110 0101

Then, look up each group in a table:

Binary: 0000 0001 0010 0011 0100 0101 0110 0111

Hexadecimal: 0 1 2 3 4 5 6 7

Binary: 1000 1001 1010 1011 1100 1101 1110 1111

Hexadecimal: 8 9 A B C D E F

Binary = 1110 0101

Hexadecimal = E 5 = E5 hex

OCTAL TO OTHER

1. OCTAL TO BINARY

Converting from octal to binary is as easy as converting from binary to octal. Simply look up each octal digit to obtain the equivalent group of three binary digits.

Octal: 0 1 2 3 4 5 6 7

Binary: 000 001 010 011 100 101 110 111

Octal = 3 4 5

Binary = 011 100 101 = 011100101 binary

2. OCTAL TO HEXADECIMAL

When converting from octal to hexadecimal, it is often easier to first convert the octal number into binary and then from binary into hexadecimal. For example, to convert 345 octal into hex:

(from the previous example)

Octal = 3 4 5

Binary = 011 100 101 = 011100101 binary

Drop any leading zeros or pad with leading zeros to get groups of four binary digits (bits):

Binary 011100101 = 1110 0101

Then, look up the groups in a table to convert to hexadecimal digits.

Binary: 0000 0001 0010 0011 0100 0101 0110 0111

Hexadecimal: 0 1 2 3 4 5 6 7

Binary: 1000 1001 1010 1011 1100 1101 1110 1111

Hexadecimal: 8 9 A B C D E F

Binary = 1110 0101

Hexadecimal = E 5 = E5 hex

Therefore, through a two-step conversion process, octal 345 equals binary 011100101 equals hexadecimal E5.

3. OCTAL TO DECIMAL

The conversion can also be performed in the conventional mathematical way, by showing each digit place as an increasing power of 8.

345 octal = (3 * 8^2 ) + (4 * 8^1 ) + (5 * 8^0 ) = (3 * 64) + (4 * 8) + (5 * 1) = 229 decimal

OR

Converting octal to decimal can be done with repeated division.

  1. Start the decimal result at 0.
  2. Remove the most significant octal digit (leftmost) and add it to the result.
  3. If all octal digits have been removed, you’re done. Stop.
  4. Otherwise, multiply the result by 8.
  5. Go to step 2.

Octal Digits Operation Decimal Result Operation Decimal Result

345 +3 3 × 8 24 45 +4 28 × 8 224 5 +5 229 done.

1's complement

The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's. This is called as taking complement or 1's complement. Example of 1's Complement is as follows.

Binary Addition

It is a key for binary subtraction, multiplication, division. There are four rules of binary addition.

In fourth case, a binary addition is creating a sum of (1 + 1 = 10) i.e. 0 is written in the given column and a carry of 1 over to the next column.

Example − Addition

2's complement

The 2's complement of binary number is obtained by adding 1 to the Least Significant Bit (LSB) of 1's complement of the number.

2's complement = 1's complement + 1

Example of 2's Complement is as follows.

00000111

1 1 0 ) 0 0 1^1 0 1 0 1 0 = 42 (base 10)

  • (^1 1 0) = (^6) (base 10)

(^1) borrows 1 0^1 0 1

  • 1 1 0

1 1 0

  • 1 1 0

0

10000111 ÷ 00000101 = 00011011

(^1 1 0 1 1) = (^27) (base 10)

1 0 1 ) 1 0 0^1 0 0 1 1 1 = 135 (base

  • (^1 0 1) = (^5) (base 10)

1 1^1 0

  • 1 0 1

1 1

  • 0

1 1 1

  • 1 0 1

1 0 1

  • 1 0 1

0

Example − Division

HTML

Tags are containers. The html tag indicates that everything between and is code that conforms to the standards of the type of HTML. Everything between the opening tag and closing tag are inside that tag and therefore have the attributes that tag gives them. Those attributes can be modified.

SR. NO

TAG NAME

ATTRIBUT ES

DESCRIPTION EXAMPLE

  1. (^) The followin g elements can go inside the

    element:

The <head> element is a container for all the head elements.

The <head> element can include a title for the document, scripts, styles, meta information, and more.

<!DOCTYPE html> <html> <head> <title>Title of the document

The content of the document......

  1. href target=_b lank

_parent

_self

_top

The tag defines a hyperlink, which is used to link from one page to another.

The most important attribute of the element is the href attribute, which indicates the link's destination.

Title of the document

Visit yahoo.com!

  1. 3.

    align The

    tag defines a paragraph.

    Title of the document

<p>This is some text in a paragraph.</p>
  1. color face size

The tag specifies the font face, font size, and color of text.

Title of the document

This is some text! This is some text! This is some text!

align (^) The to tags are used to define HTML headings.

defines the most important heading. defines the least important heading.

Title of the document

This is heading 1 This is heading 2 This is heading 3

## XML

XML stands for E xtensible M arkup L anguage and is a text-based markup language derived from Standard Generalized Markup Language (SGML).

XML tags identify the data and are used to store and organize the data, rather than specifying how to display it like HTML tags, which are used to display the data. XML is not going to replace HTML in the near future, but it introduces new possibilities by adopting many successful features of HTML.

There are three important characteristics of XML that make it useful in a variety of systems and solutions:

XML is extensible: XML allows you to create your own self-descriptive tags, or language, that suits your application.

XML carries the data, does not present it: XML allows you to store the data irrespective of how it will be presented.

XML is a public standard: XML was developed by an organization called the World Wide Web Consortium (W3C) and is available as an open standard.

XML Usage

A short list of XML usage says it all:

 XML can work behind the scene to simplify the creation of HTML documents for large web sites.

 XML can be used to exchange the information between organizations and systems.

 XML can be used for offloading and reloading of databases.

 XML can be used to store and arrange the data, which can customize your data handling needs.

 XML can easily be merged with style sheets to create almost any desired output.

 Virtually, any type of data can be expressed as an XML document.

XML is a markup language that defines set of rules for encoding documents in a format that is both human-readable and machine-readable. So what exactly is a markup language? Markup is information added to a document that enhances its meaning in certain ways, in that it identifies the parts and how they relate to each other. More specifically, a markup language is a set of symbols that can be placed in the text of a document to demarcate and label the parts of that document.

Following example shows how XML markup looks, when embedded in a piece of text:

Hello, world!

This snippet includes the markup symbols, or the tags such as ... and ... . The tags and mark the start and the end of the XML code fragment. The tags and surround the text Hello, world!.

Example:

Tanmay Patil

TutorialsPoint

(011) 123- 4567

The following diagram depicts the syntax rules to write different types of markup and text in an XML document.

Each component of the above diagram in detail:

XML Declaration

The XML document can optionally have an XML declaration. It is written as below:

Where version is the XML version and encoding specifies the character encoding used in the document.

Syntax Rules for XML declaration

 The XML declaration is case sensitive and must begin with "" where "xml" is written in lower-case.

 If document contains XML declaration, then it strictly needs to be the first statement of the XML document.

 The XML declaration strictly needs be the first statement in the XML document.

CSS

C ascading S tyle S heets, fondly referred to as CSS, is a simple design language intended to simplify the process of making web pages presentable.

CSS handles the look and feel part of a web page. Using CSS, you can control the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used, layout designs,variations in display for different devices and screen sizes as well as a variety of other effects.

CSS is easy to learn and understand but it provides powerful control over the presentation of an HTML document. Most commonly, CSS is combined with the markup languages HTML or XHTML.

Advantages of CSS

CSS saves time − You can write CSS once and then reuse same sheet in multiple HTML pages. You can define a style for each HTML element and apply it to as many Web pages as you want.

Pages load faster − If you are using CSS, you do not need to write HTML tag attributes every time. Just write one CSS rule of a tag and apply it to all the occurrences of that tag. So less code means faster download times.

Easy maintenance − To make a global change, simply change the style, and all elements in all the web pages will be updated automatically.

Superior styles to HTML − CSS has a much wider array of attributes than HTML, so you can give a far better look to your HTML page in comparison to HTML attributes.

Multiple Device Compatibility − Style sheets allow content to be optimized for more than one type of device. By using the same HTML document, different versions of a website can be presented for handheld devices such as PDAs and cell phones or for printing.

Global web standards − Now HTML attributes are being deprecated and it is being recommended to use CSS. So its a good idea to start using CSS in all the HTML pages to make them compatible to future browsers.

Offline Browsing − CSS can store web applications locally with the help of an offline catche.Using of this, we can view offline websites.The cache also ensures faster loading and better overall performance of the website.

Platform Independence − The Script offer consistent platform independence and can support latest browsers as well.

A CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in your document. A style rule is made of three parts −

Selector − A selector is an HTML tag at which a style will be applied. This could be any tag like or etc.

Property - A property is a type of attribute of HTML tag. Put simply, all the HTML attributes are converted into CSS properties. They could be color , border etc.

Value - Values are assigned to properties. For example, color property can have value either red or #F1F1F1 etc.

You can put CSS Style Rule Syntax as follows −

selector { property: value }

Example: You can define a table border as follows −

table{ border :1px solid #C00; }

Here table is a selector and border is a property and given value 1px solid #C00 is the value of that property.

You can define selectors in various simple ways based on your comfort. Let me put these selectors one by one.

The Type Selectors

This is the same selector we have seen above. Again, one more example to give a color to all level 1 headings:

h1 {

color: #36CFFF;

}

The Universal Selectors

The ID Selectors

You can define style rules based on the id attribute of the elements. All the elements having that id will be formatted according to the defined rule.

#black {

color: #000000;

}

This rule renders the content in black for every element with id attribute set to black in our document. You can make it a bit more particular. For example −

h1#black {

color: #000000;

}

This rule renders the content in black for only elements with id attribute set to black.

The true power of id selectors is when they are used as the foundation for descendant selectors, For example:

#black h2 {

color: #000000;

}

In this example all level 2 headings will be displayed in black color when those headings will lie with in tags having id attribute set to black.

Example:

This is a heading

This is a paragraph.

Inline CSS - The style Attribute

You can use style attribute of any HTML element to define style rules. These rules will be applied to that element only. Here is the generic syntax −

Attributes

Attribute Value Description

style style rules The value of style attribute is a combination of style declarations

separated by semicolon (;).

Example

Following is the example of inline CSS based on the above syntax −

This is inline CSS