21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Numbers 12<br />

Numbers<br />

<strong>OpenOffice</strong>.<strong>org</strong> Basic supports five basic types for processing numbers:<br />

• Integer<br />

• Long Integer<br />

• Single<br />

• Double<br />

• Currency<br />

Integer Variables<br />

Integer variables can store any whole number between -32768 and 32767. An integer<br />

variable can take up to two bytes of memory. The type declaration symbol for an integer<br />

variable is %. Calculations that use integer variables are very fast and are particularly<br />

useful for loop counters. If you assign a floating point number to an integer variable, the<br />

number is rounded up or down to the next whole number.<br />

Example declarations for integer variables:<br />

Dim Variable As Integer<br />

Dim Variable%<br />

Long Integer Variables<br />

Long integer variables can store any whole number between –2147483648 and<br />

2147483647. A long integer variable can takes up to four bytes of memory. The type<br />

declaration symbol for a long integer is &. Calculations with long integer variables are very<br />

fast and are particularly useful for loop counters. If you assign a floating point number to a<br />

long integer variable, the number is rounded up or down to the next whole number.<br />

Example declarations for long integer variables:<br />

Dim Variable as Long<br />

Dim Variable&<br />

Single Variables<br />

Single variables can store any positive or negative floating point number between<br />

3.402823 x 10 38 and 1.401298 x 10 -45 . A single variable can take up to four bytes of<br />

memory. The type declaration symbol for a single variable is !.<br />

Originally, single variables were used to reduce the computing time required for the more<br />

precise double variables. However, these speed considerations no longer apply, reducing<br />

the need for single variables.<br />

Example declarations for single variables:<br />

Dim Variable as Single

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!