Basic Data Types
There are 4 basic data types: Integer, Float, String, and Pointer.
Integer
Integer are numeric values with no fractional part in them, int32 in essence. For example: 5, -10, 0 are integer values. All integer values in the program must be in the range -2147483648 to +2147483647.
Digit separator
Digit separator _ can be used to separate a long literal number. For example, 3_14_15_926 is equavlant to 31415926.
Float
Float are numeric values that include a fractional part. For example: .5, -10.1, 0.0 are all floating point values. You can also use Digit separator to separate literal.
String
String are used to contain text. For example: "Hello World!".
Escape characters
You need to use escape characters to insert " or line feed in a literal string. This is a modern alternative to Chr function.
Character |
Result |
|---|---|
|
single quote |
|
double quote |
|
backslash |
|
new line |
|
carriage return |
|
tab |
|
backspace |
|
form feed |
The example below shows the usage of the escape character. Both of them print Hello"World!. It is recommended to replace the legacy BlitzBasic method with escape characters, as it processes at compile time and produces fewer string objects at runtime.
1Print("Hello\"World!")
2Print("Hello" + Chr(34) + "World!")
Pointer
Pointer are objects that store a memory address. This type is for solving that pointers are stored in an integer in BlitzBasic.
When assigning a pointer to an integer variable, ZiYue4D will automatically raise the variable to pointer type.
Implicit conversion
Implicit conversion plays an important role in ZiYue4D. Most of the conversion in ZiYue4D is implicit, and observes the same rules as in BlitzBasic.
When an binary operation involves two different data types, ZiYue4D will automatically convert one of the operands to the other type. The conversion rules are as follows:
Pointers cannot be converted to any other type, and no other type can be converted to pointers. [1]
If one operand is a string, the other is converted to a string.
If one operand is floating point, the other is converted to floating point.
Otherwise, both operands are integers.
From \ To |
Integer |
Float |
String |
Pointer |
|---|---|---|---|---|
Integer |
✅ |
✅ |
✅ |
❌ |
Float |
❗ [2] |
✅ |
✅ |
❌ |
String |
❌ |
❌ |
✅ |
❌ |
Pointer |
❗ [3] |
❌ |
❌ |
✅ |
Footnotes