15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

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

Declaring Constants 579<br />

Declaring decimal data types<br />

Decimal values are numbers such as 1.88 or –91.4. Just as you can limit the<br />

range of integer values a variable can hold, so can you limit the range of decimal<br />

values a variable can hold. In Visual Basic, the four types of decimal<br />

data types are Single, Double, Currency, and Extended, as shown in<br />

Table 4-2.<br />

Table 4-2<br />

Pascal Decimal Data Types<br />

Data Type Number of Bytes Range<br />

Single 4 1.5 E–45 to 3.4 E38<br />

Double 8 5.0 E–324 to 1.7 E308<br />

Currency 8 -922,337,203,685,477.5808 to<br />

922,337,203,685,477.5807<br />

Extended 10 3.4 E–4932 to 1.1 E4932<br />

Book VI<br />

Chapter 4<br />

Pascal and Delphi<br />

To declare a variable as a decimal data type, use the Single, Double,<br />

Currency, or Extended keyword, such as<br />

Var<br />

Variablename1 : Single;<br />

Declaring Boolean values<br />

Besides storing text and numbers, variables can also hold a Boolean value —<br />

True or False. To declare a variable to hold a Boolean value, use the<br />

Boolean keyword as follows:<br />

Var<br />

Variablename1 : Boolean;<br />

Declaring Constants<br />

Constants always represent a fixed value. In Pascal, you can declare a constant<br />

and its specific value as follows:<br />

Const<br />

Constantname1 = value;<br />

So if you wanted to assign 3.14 to a pi constant, you could do this:<br />

Const<br />

pi = 3.14;

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

Saved successfully!

Ooh no, something went wrong!