Data Handling

The care of numbers constitutes an important part of every programming system.  Fortunately, PowerBASIC allows you to ignore most technical considerations about internal number handling.  If you never give a thought to such matters as calculation speed, precision, and memory requirements, your programs will usually continue to work as you expect.  However, an understanding of the underlying issues will help when you need to write programs that are faster, more accurate, and require less memory.

For efficiency, PowerBASIC stores and processes data in different forms.  It supports eleven unique numeric types, three string types, and also pointers.  The following tables summarize the most important features and distinctions of these data types.  The rest of this section explains these features in detail.

Numeric Data storage requirements and ranges

Data Type

Size

Decimal Range

Binary Range

Integer

16 bits (2 bytes), signed

-32,768 to 32,767

-2^15 to 2^15-1

Long-integer

32 bits (4 bytes), signed

-2,147,483,648 to 2,147,483,647

-2^31 to 2^31-1

Quad-integer

64 bits (8 bytes), signed

-9.22*10^18 to +9.22*10^18

-2^63 to 2^63-1

Byte

8 bits (1 byte), unsigned

0 to 255

0 to 2^8 -1

Word

16 bits (2 bytes), unsigned

0 to 65,535

0 to 2^16 -1

Double-word

32 bits (4 bytes), unsigned

0 to 4,294,967,295

0 to 2^32 -1

Single-precision

32 bits (4 bytes)

8.43*10^-37 to 3.40*10^38

 

Double-precision

64 bits (8 bytes)

4.19*10^-307 to 1.79*10^308

 

Extended-precision

80 bits (10 bytes)

3.4*10^-4932 to 1.2*10^4932

 

Currency

64 bits (8 bytes)

-9.22*10^14 to +9.22*10^14

 

Extended-currency

64 bits (8 bytes)

-9.22*10^16 to +9.22*10^16

 

Variant

128 bits (16 bytes)

{data-dependent}

{data-dependent}

 Variable type-specifiers and keywords

Variable type

Type specifier

Element size

DEF type

Type keyword

Pointer

N/A

4

N/A

PTR/POINTER

Integer

%

2

DEFINT

INTEGER

Long-integer

&

4

DEFLNG

LONG

Quad-integer

&&

8

DEFQUD

QUAD

Byte

?

1

DEFBYT

BYTE

Word

??

2

DEFWRD

WORD

Double-word

???

4

DEFDWD

DWORD

Single-precision

!

4

DEFSNG

SINGLE

Double-precision

#

8

DEFDBL

DOUBLE

Extended-precision

##

10

DEFEXT

EXT/EXTENDED

Currency

@

8

DEFCUR

CUR/CURRENCY

Extended-currency

@@

8

DEFCUX

CUX/CURRENCYX

String

$

4

DEFSTR

STRING

Fixed-length string

N/A

N/A

N/A

STRING * x

ASCIIZ string

N/A

N/A

N/A

ASCIIZ, ASCIZ

FIELD string

$

16

N/A

FIELD

Variant

N/A

16

N/A

VARIANT

GUID

N/A

16

N/A

GUID

OBJECT

N/A

4

N/A

DISPATCH