Type Characters
There are some characters that have an effect on the data type of some programming elements. These characters can be symbols you attach to the end of an identifier or literal. Others are alphanumeric suffixes you attach to literals to give them a different data type.
Identifier type characters
ViviFire supplies a set of identifier type characters that you can use to specify the data type of a variable or constant. The table that follows shows the available identifier type characters with code examples.
Type character | Data type | Example |
---|---|---|
% |
Int32 |
|
! |
Real64 |
|
@ |
Fixed64 |
|
$ |
String |
|
There are no identifier type characters for the data types Boolean
, Char
, Fixed128
, Int8
, Int16
, Int64
, Int128
, Real32
, Real128
, SafeString
, SBits
, UBits
, or UInt8
thru UInt128
.
Also, compound data types, for example, arrays and structures do not have an identifier type character.
Literal type characters
Default literal types
The qualities of a literal usually give it its data type. The table that follows gives the defaults.
Qualities of a literal | Default data type | Examples |
---|---|---|
Number, no fraction part | Int32 |
|
Number with a fraction part | Real64 |
|
Between two backtick symbols | Char |
|
Starts with a percent symbol and a minimum of two letters | Int32 |
|
Between two quotation symbols | String |
|
Starts with a dollar symbol | String |
|
Three groups of numbers connected with slashes, hyphens, or colons | DateTime |
|
Starts with an at-symbol or currency symbol, number | Fixed64 |
|
Three or four groups of numbers connected with dots | version number |
|
Special literal types
ViviFire supplies a set of literal type suffixes, which let you select a data type different from the default, given its qualities. You attach a suffix to the end of the literal. The table that follows shows the available literal type suffixes with examples.
Literal suffix | Data type | Example |
---|---|---|
I8 or i8 |
Int8 |
|
I16 or i16 |
Int16 |
|
I32 or i32 |
Int32 |
|
I64 or i64 |
Int64 |
|
I128 or i128 |
Int128 |
|
D64 or d64 |
Fixed64 |
|
D128 or d128 |
Fixed128 |
|
R32 or r32 |
Real32 |
|
R64 or r64 |
Real64 |
|
R128 or r128 |
Real128 |
|
U8 or u8 |
UInt8 |
|
U16 or u16 |
UInt16 |
|
U32 or u32 |
UInt32 |
|
U64 or u64 |
UInt64 |
|
U128 or u128 |
UInt128 |
|
There are no literal type characters for Boolean
, Char
, DateTime
, SafeString
, or String
.
And there are none for compound data types, for example, arrays and structures.
Literals can also use the identifier type characters !
and @
.
But, identifiers cannot use the special literal types.
Hexadecimal, octal, and binary literals
Number base | Prefix | Available digits | Examples |
---|---|---|---|
Hexadecimal (base 16) | %X or %x |
0–9 A–F |
|
Octal (base 8) | %O or %o |
0–7 |
|
Binary (base 2) | %B or %b |
0 1 |
|
Note:
Hexadecimal literals must have a number (0–9) or underscore (_
) immediately after X.
If you put a letter after X, it will possibly be seen as a named constant.