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.

Identifier type characters
Type characterData typeExample
% Int32
Var x%
! Real64
Var x!
@ Fixed64
Var x@
$ String
Var x$

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
32768 32_768
Number with a fraction part <Real64
3.14159 4.1e-8
Between two backtick symbols Char
`A` `@`
Starts with a percent symbol and a minimum of two letters Int32
%CR %RETURN
Between two quotation symbols String
"Hello, world!"
Starts with a dollar symbol String
$CR $13 $LINE
$"Hello, {name}!"
Three groups of numbers connected with slashes, hyphens, or colons DateTime
2013/12/11
2013-12-11 10:09:08
Starts with an at-symbol or currency symbol, number Fixed64
@12.34 @$12.34 ¤12.34
@£1_234_567.89
Three or four groups of numbers connected with dots version number
1.2.3.4
1.22.333

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 suffixData typeExample
I8 or i8 Int8
123I8
I16 or i16 Int16
123i16
I32 or i32 Int32
123I32
I64 or i64 Int64
123I64
I128 or i128 Int128
123i128
D64 or d64 Fixed64
123D64
D128 or d128 Fixed128
123d128
R32 or r32 Real32
123R32
R64 or r64 Real64
123R64
R128 or r128 Real128
123r128
U8 or u8 UInt8
123U8
U16 or u16 UInt16
123u16
U32 or u32 UInt32
123U32
U64 or u64 UInt64
123U64
U128 or u128 UInt128
123u128

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
%X0FFF %x0ff_00_2a %x7b_i8
Octal (base 8) %O or %o 0–7
%O777 %o377_777
Binary (base 2) %B or %b 0 1
%B101010 %b11111111_11111111

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.

See also