Microsoft Access VBA Tutorials for self-paced learning, Class Modules, SQL Techniques, and AI Integration Guides.

Octal Number System

Continued from Last Week's Post. Octal Number System.

This is the continuation of earlier Articles:

1.  Learn the Binary Number System.

2.  Learn Binary Number System-2.

Please refer to the earlier Articles before continuing.

We will take the result of the Decimal (Base 10) Number 255 converted to Binary for a closer look at these two numbers: 11111111.

The decimal value 255 is represented using only three decimal digits. However, when the same value is expressed in binary, it requires eight binary digits (bits) to represent the identical quantity.  Earlier, Computer Programs were written using Binary Instructions.  Look at the example code given below:

Later, programming languages like Assembly Language were developed using Mnemonics (8-bit-based Binary instructions) ADD, MOV, POP, etc.  Present-day Compilers for high-level languages are developed using Assembly Language. A new number system was devised to write binary numbers in short form.

Octal Number System.

The Octal number system has the decimal number 8 as its base and is known as the Octal Numbers.  Based on the general rule we have learned, Octal Numbers have digits 0 to 7 (one less than the base value 8) to write numerical quantities. Octal Numbers don't have digits 8 or 9. This Number System has been devised to write Binary Instructions for Computers in a shorter form and to write program codes easily.

For example, an 8-bit Binary instruction looks like the following:

00010111  (instruction in Octal form 027), ADD B, A (Assembly Language).

The first two bits (00) represent the operation code ADD, the next three bits (010) represent CPU Register B, and the next three bits (111) represent CPU Register A. The 8-bit binary instruction adds register A to B.  If the instruction must be changed to (ADD A, B), add the contents of register B to A, then the last six bits must be altered to 00,111,010. This can be easily understood if it is written in Octal  027 to 072 rather than Binary 00111010.

The Octal (Base-8) Number System was developed as a compact way to represent binary-based instructions. Returning to the Octal Number System, let us examine how these numbers are used. To begin, we will create a table similar to those used for the Decimal and Binary Number Systems.

85 84 83 82 81 80
32768 4096 512 64 8 1
           

We will use the same methods used for Binary to convert Decimal to Octal Numbers.

Example: Converting 255 into an Octal Number.

We cannot use the binary-to-decimal style conversion method for octal numbers. Looking at the table, we can see that 512 is greater than 255, so it cannot be used. The next lower value is 64, and our task is to determine how many times 64 can fit into 255.

Method-1:

255/64 = Quotient 3, Remainder 63 (Here, we have to take the Quotient as the Octal Digit).

In this method, we must take the quotient 3 (64 x 3 = 192) for our result value, and the balance is 63 (i.e., 255 - 192)

85 84 83 82 81 80
32768 4096 512 64 8 1
      3    

63/8 = Quotient  7, Remainder 7

85 84 83 82 81 80
32768 4096 512 64 8 1
      3 7  

7 is not divisible by 8; hence, 7 goes into the Units position

85 84 83 82 81 80
32768 4096 512 64 8 1
      3 7 7

Method-2:

255/8 = Quotient = 31, Remainder=7

85 84 83 82 81 80
32768 4096 512 64 8 1
          7

31/8 = Quotient = 3, Remainder=7

85 84 83 82 81 80
32768 4096 512 64 8 1
        7 7

3 is not divisible by 8; hence, it is taken to the third digit position.

85 84 83 82 81 80
32768 4096 512 64 8 1
      3 7 7

Writing Binary to Octal Short Form.

As I mentioned earlier, the Octal Number System was devised to express Binary in a shorter form.  Let us see how we can do this and convert binary numbers easily into Octal numbers.

When the decimal number 255 is converted into Binary, we get 11111111. To convert it into Octal Numbers, organize the binary digits into groups of three bits (011,111,111) from right to left, add up the binary values of each group, and write the Octal value.

011 = 1+2 = 3

111 = 1+2+4 = 7

111 = 1+2+4 = 7

Result: = 377 Octal.

To get a better grasp of this Number System, try converting a few more numbers on your own. Start by converting some decimal numbers into binary, then group the binary digits into sets of three bits. Next, calculate the value of each group as though they represent the first three bits of a binary number.

Since octal numbers use digits 0 through 7, they can easily be mistaken for decimal numbers by both humans and machines. To avoid confusion, octal numbers are always written with a prefix. In MS Access VBA, the prefix is &O (the letter O, not case-sensitive) or &0 (digit zero). For example, the octal number 377 can be written as &O0377, &O377, or &0377.

You can try this by typing the number in the Debug Window of Microsoft Access or Excel.

Examples:

? &O0377

Result: 255

? &0377

Result: 255

? &0377 * 2

Result: 510

Next, we will learn the Base-16 (Hexadecimal) Number System.

Technorati Tags: .
  1. Learn the Binary Numbering System
  2. Learn Binary Numbering System-2
  3. Octal Numbering System
  4. Hexadecimal Numbering System
  5. Colors 24-Bits And Binary Conversion.
  6. Create Your Own Color Palette
Share:

No comments:

Post a Comment

Comments subject to moderation before publishing.

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet External Links Queries Array Class Module msaccess reports Accesstips msaccess tips WithEvents Downloads Objects Menus and Toolbars MsaccessLinks Process Controls Art Work Collection Object Property msaccess How Tos Combo Boxes ListView Control Query VBA msaccessQuery Calculation Dictionary Object Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes Recordset Top Values Variables msaccess email progressmeter Access2007 Copy Excel Expression Fields Join Methods Microsoft Numbering System RaiseEvent Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup Wrapper Classes database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler Export External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code