Constants
A constant data type is determined by its syntax. In PV-WAVE there are eight basic data types, each with its own form of constant:
BYTE—8-bit unsigned integers.
INT—16-bit signed integers.
INT32—32-bit signed integers.
LONG—64-bit signed integers on 64-bit platforms; 32-bit signed integers on all other platforms.
FLOAT—32-bit single-precision floating-point.
DOUBLE—64-bit double-precision floating-point.
COMPLEX—Real-imaginary pair using single-precision floating-point.
DCOMPLEX—Real-imaginary pair using double-precision floating-point.
STRING—Zero or more eight-bit characters which are interpreted as text.
Integer Constants
Numeric constants of different types may be represented by a variety of forms. The syntax of integer constants is shown in the following table, where “n” represents one or more digits.
Radix |
Type |
Form |
Examples |
Decimal |
BYTE |
nB |
12B, 34B |
INT |
n |
12, 425 |
|
INT32 |
nI |
12I, 94I |
|
LONG |
nL |
12L, 94L |
|
Hexadecimal |
BYTE |
'n'XB |
'2E'XB |
INT |
'n'X |
'0F'X |
|
INT32 |
nI |
12I, 94I |
|
LONG |
'n'XL |
'FF'XL |
|
Octal |
BYTE |
"nB |
"12B |
INT |
"n |
"12 |
|
'n'O |
'377'O |
||
INT32 |
nI |
12I, 94I |
|
LONG |
"nL |
"12L |
|
'n'OL |
'777777'OL |
Values of integer constants can range from 0 to 255 for BYTEs, 0 to ± 32,767 for INTs, 0 to ± 232 for INT32s, and 0 to ± 232 (on 32-bit systems) or 0 to ± 264 (on 64-bit systems) for LONGs. Integers that are initialized with absolute values greater than 32,767 are automatically typed as longword. Any numeric constant may be preceded by a + or a – sign. To ensure cross-platform compatibility, place the + or a – sign outside of the apostrophe.
Floating-point and Double-precision Constants
Floating-point and double-precision constants may be expressed in conventional or scientific notation. Any numeric constant that includes the decimal point is a floating-point or double-precision constant.
The syntax of floating-point and double-precision constants is shown in Syntax of Floating-point and Double-precision Constants . The notation sx represents the sign and magnitude of the exponent, for example: E-2
.
Double-precision constants are entered in the same manner, replacing E
with a D
. For example, 1.0D0
, 1D
, 1.D
, all represent a double precision one.
Form |
Double Precision |
Floating Point |
n . |
102.D |
102. |
. n |
.102D |
.102 |
n .n |
10.2D |
10.2 |
n Xsx |
10D5 |
10E5 |
n .Xsx |
10.D–3 |
10.E–3 |
.n Xsx |
.1D+12 |
.1E+12 |
n .n Xsx |
2.3D12 |
2.3E12 |
Complex Constants
Complex constants contain a real and an imaginary part, which can be of single or double-precision floating point numbers. The imaginary part may be omitted, in which case it is assumed to be zero.
The form of a complex constant is:
COMPLEX(real_part, imaginary_part)
or:
COMPLEX(real_part)
For example, COMPLEX(1, 2)
, is a complex constant with a real part of one, and an imaginary part of two. COMPLEX(1)
is a complex constant with a real part of one and a zero imaginary component.
The ABS function returns the magnitude of a complex expression. To extract the real part of a complex expression, use the FLOAT function; to extract the imaginary part, use the IMAGINARY function. These functions are explained in the (Undefined variable: pvwave.waveur).
String Constants
A string constant consists of zero or more characters enclosed by apostrophes ( ' ) or quotation marks ( " ). The value of the constant is simply the characters appearing between the leading delimiter ( ' or " ) and the next occurrence of the delimiter.
A double apostrophe ( ' ' ) or double quotation mark ( " " ) is considered to be the null string; a string containing no characters.
An apostrophe or quotation mark may be represented within a string that is delimited by the same character, by two apostrophes, or quotation marks. For example, 'Don''t'
produces Don't
; or you can write: "Don't"
to produce the same result.
Examples of Correct String Constants illustrates valid string constants.
String Value |
Correct |
Hi there |
|
Hi there |
|
Null String |
|
I’m happy |
|
I’m happy |
|
counter |
|
129 |
|