Visual Basic 2008 9.0 .NET Examples and Ebook
  Home

Introduction to Visual Basic

Arrays

Volgend Onderwerp

Numeric Integral Datatypes - Byte Short Integer Long

Vorig Onderwerp

Operators

|

Numeric Decimal Datatypes - Single Double Decimal

Volgend Onderwerp
Unsigned Integral Datatypes

Unsigned Integral Datatypes

Signed Integral Datatypes

Signed Integral Datatypes



To represent integral values ( without digits after the decimal separator ) :


 Byte     Byte    1 byte  0 <-> 255 ( unsigned )
 SByte    SByte   1 byte  -128 <-> +127 ( signed )

 Short    Int16   2 bytes -32,768 <-> +32,767 ( signed )
 UShort   UInt16  2 bytes 0 <-> 65,535 ( unsigned )

 Integer  Int32   4 bytes -2,147,483,648 <-> +2,147,483,647 ( signed )
                          about -2 to +2 billion ( short scale )
                          about -2 to +2 milliard ( long scale )
 UInteger UInt32  4 bytes 0 <-> 4,294,967,295 ( unsigned )
                          0 to about 4 billion ( short scale )
                          0 to about 4 milliard ( long scale )

 Long     Int64   8 bytes -9,223,372,036,854,775,808 <->
                          +9,223,372,036,854,775,807 ( signed )
                          about -9 to +9 quintillion ( short scale )
                          about -9 to +9 trillion ( long scale )
 ULong    UInt64  8 bytes 0 <-> 18,446,744,073,709,551,615 ( unsigned )
                          0 to about 18 quintillion ( short scale )
                          0 to about 18 trillion ( long scale )

The first column contains the Visual Basic names for these datatypes. These are specific for the use within the language Visual Basic.
The second column contains the .NET names for these datatypes. These can also be used within each CLR ( Common Language Runtime ) compliant language ( including Visual Basic ).
All .NET languages use common datatypes, these datatypes are defined in the CLT ( Common Language Types ) of .NET.

The S and U prefixes stand for "Signed" and "Unsigned", indicating whether or not a sign-bit is used for these datatypes.


Unsigned Integral Datatypes


Unsigned datatype Byte internally uses 1 byte ( or 8 bits ) to represent its value. If 8 bits can be either 0 or 1, 2^8 ( or 256 ) possible values can be represented.
Starting with 0 ( [0000 0000] ), up to 255 ( [1111 1111] ).


Klik hier om terug naar boven te gaan.  Up


Signed Integral Datatypes


The most significant bit ( MSB ) ( leftmost bit ) is used for the sign. Positive is indicated with 0, negative with 1. All other bits ( for instance all 7 other bits of type 'SByte' ) are used to represent the value in two's compliment.

We know condition 7 And Not 7 = 0 evaluates to True. 7 is binary represented as [0000 0111], Not 7 must then be [1111 1000], because [0000 0111] And [1111 1000] results in [0000 0000].
The first [1] of [1111 1000] indicates this is a negative value. The rest of of the bits [111 1000] is in twos compliment, so well have to invert then and add [1], so [000 0111] + [1] results in [000 1000] ( or 8). Not 7 is -8.

Some numbers in SByte representation :


          sign-bit
    0 -> [0        000 0000]

   +1 -> [0        000 0001]
   +2 -> [0        000 0010]
 +126 -> [0        111 1110]
 +127 -> [0        111 1111] -> maximum value

   -1 -> [1        111 1111]
   -2 -> [1        111 1110]
 -126 -> [1        000 0010]
 -127 -> [1        000 0001]
 -128 -> [1        000 0000] -> minimum value

All other unsigned integral datatypes ( Short, Integer en Long ) use identical internal representation, but use more bits for it, leading to larger values that can be represented.


Updated On : 2008-10-25

Published On : 2008-11-06

Numeric Integral Datatypes - Byte Short Integer Long

Vorig Onderwerp

Operators

|

Numeric Decimal Datatypes - Single Double Decimal

Volgend Onderwerp

Introduction to Visual Basic

Arrays

Volgend Onderwerp
  Home  
Nederlands
Nederlands

Add to favorites (IE).


No printable version available.