BrainDump
  Home arrow BrainDump arrow Page 3 - Understanding Numeric Data in VBScript
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Understanding Numeric Data in VBScript
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-02-26

    Table of Contents:
  • Understanding Numeric Data in VBScript
  • Numeric Subtypes and Precision
  • Number systems
  • Conversion Functions
  • Converting data types

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Understanding Numeric Data in VBScript - Number systems


    (Page 3 of 5 )

    Keeping in mind that computers interpret bit patterns, humans on the other hand must use more friendly numbers.  Different number systems have been devised to ease interpreting different types of numbers.

    By far the most common among these number systems is the decimal system that we use every day.  This base-10 system was designed to make mathematical calculations much easier—for the human mind that is.  The decimal system is harder for computers.

    Computer hardware uses the base-2 binary system.  This is because CPUs use transistors to perform logical calculations.  A transistor has two states: open and closed.  This made the binary system a natural choice.

    A number system’s base implies the number of possibilities for each digit in a number.  Since the binary system allows only two possibilities, it is much faster for a CPU to use these types of numbers.  Let’s take a look at the digit possibilities for common number systems:

    • Binary system – 0, 1
    • Octal system – 0, 1, 2, 3, 4, 5, 6, 7
    • Decimal system – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    • Hexadecimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

    In hexadecimal (base-16) there are sixteen possibilities for each digit.  Since they can’t be expressed in single decimal digits, letters are used to represent the values 11 to 15.

    Counting in Different Number Systems

    Bin

    Dec

    Hex

    Bin

    Dec

    Hex

    Bin

    Dec

    Hex

    0

    0

    0

    1001

    8

    8

    10001

    16

    10

    1

    1

    1

    1010

    9

    9

    10010

    17

    11

    10

    2

    2

    1011

    10

    A

    10011

    18

    12

    11

    3

    3

    1100

    11

    B

    10100

    19

    13

    100

    4

    4

    1101

    12

    C

    10101

    20

    14

    101

    5

    5

    1110

    13

    D

    10110

    21

    15

    110

    6

    6

    1111

    14

    E

    10111

    22

    16

    1000

    7

    7

    10000

    15

    F

    11000

    23

    17

    All number systems increment by one starting at zero.  Adding numbers in each system is done identically—increment the furthest right digit by one; if it is already at its maximum, reset it to zero and carry to the next place.

    An example in hex would be 4A6FF + 1 = 4A700.

    Since numbers inherently represent the same quantities, and the mathematical operations on them are the identical, numbers can be converted from one system to another.  Since we’re dealing with computers, let’s take a look at how to convert a bit string (from binary) to both octal and hex.

    • One Octal digit equals three binary digits:

    101

    101

    011

    100

    101

    000

    001

    011

    5

    5

    3

    4

    5

    0

    1

    3

    • One Hexadecimal digit equals four binary digits:

    1011

    0101

    1100

    1010

    0000

    1011

    B

    5

    C

    A

    0

    B

    Now that you have a better understanding of number systems, let’s take a look at how VBScript makes it easier for you to work with them.

    More BrainDump Articles
    More By Nilpo


     

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT