Custom Search
 
  

 
The BASIC Character Set

There are three types of characters used in BASIC. These are: (1) alphabetic, (2) numeric, and (3) special characters.

ALPHABETIC CHARACTERS.The alphabetic characters used in BASIC are the standard English alphabet, A through Z.

NUMERIC CHARACTERS .The numeric characters used in BASIC are the digits 0 through 9.

SPECIAL CHARACTERS.The following are special characters used in BASIC:

 

=

+

-

*

/

)

(

,

.

Blank

Equal sign or assignment symbol

Plus sign

Minus sign

Asterisk or multiply symbol

Slash or divide symbol

Up-arrow or exponentiation symbol

Right parenthesis

Left parenthesis

Comma

Point or period

'

"

;

:

!

?

&

<

>

#

$

%

Single quotation mark

Double quotation mark

Semicolon

Colon

Exclamation symbol

Question mark

Ampersand

Less than symbol

Greater than symbol

Number or pound sign

Dollar sign

Percent sign

OTHER SPECIAL CHARACTERS.Some special characters are com-bined to form other elements in BASIC. The following list shows these com-binations:

> = greater than or equal

< = less than or equal

<> not equal

** exponentiation

BASIC Numbers

When you are using numeric data in a BASIC program, there are certain conventions that must be adhered to. You cannot use "$" (dollar sign), , " (comma), or the "/" (slash) in a BASIC number. There are also restrictions on the number of digits that can be used in one data element. The number of digits may vary depending upon the computer you are using. Refer to your users manual for specific instructions. Table 2-2 shows examples of correctly and incorrectly coded BASIC numbers.

Table 2-2.BASIC Numbers

Valid BASIC Numbers 

99.95 

100000.00 

+5678901.2 

.25

Invalid BASIC Numbers 

$99.95 

100,000.00 

+567890100 

1/4

Explanation

Dollar sign cannot be used

Comma cannot be used

Too many digits, only eight are allowed (decimal points, positive and negative signs do not count).

Slash cannot be used; however, this is a valid expression as an arithmetic operation (1 divided by 4).

SCIENTIFIC NOTATION.As seen in Table 2-2, in the third example, we have a number, +567890100, with too many digits. You may ask, how do we represent very large and very small numbers? Scientific notation is used. In scientific notation numbers are expressed in terms of a figure between 1 and 10 times a power of 10. The number 567890100 would be written 5.678901 x 108 in scientific notation. This method uses exponent form  

5.678901E8 = 5.678901 108 = 567890100  

Table 2-3 shows other examples of the use of E notation.

Table 2-3.E Notation

Number using E notation 

5.5E8 

5.5E-8 

2.54321E10 

2.54321E-5

Interpreted as 

550,000,000 

0.000000055 

25,432,100,000 

0.0000254321

Explanation

The decimal has been moved eight places to the right

The decimal has been moved eight places to the left

The decimal has been moved ten places to the right

The decimal has been moved five places to the left

Since were multiplying by powers of 10, the integer following the E indicates how many positions and in what direction to move the decimal point. If the integer after the letter "E" is negative, you move the decimal point to the left; if the integer is positive, you move the decimal point to the right.







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

Integrated Publishing, Inc. - A (SDVOSB) Service Disabled Veteran Owned Small Business