Literals
Literals are the simplest form of expressions. In this section, we will look at some literals.
5; // Scalar literal
4.0mm; // Quantity literal
"Hello"; // String literal
There are several types of literals:
| Name | Encoding | Description |
|---|---|---|
| Integer | 64 bit integer | signed integer |
| Scalar | 64 bit float | signed floating point |
| Boolean | 1 bit bool | boolean |
| String | UTF-8 | Text |
| Quantities | 64 bit float | signed floating point (including type) |
Integer Literals
Integer literals contain a whole number with a sign (but without a unit). Here are a few examples:
50;
1350;
-6
Scalar Literals
Scalar literals contain a floating point number with a sign (but without a unit).
1.23;
0.3252;
.4534;
1.;
-1200.0;
12.0E+12;
50% // = 0.5
Boolean Literals
Booleans contain either the value true or false:
true;
false
String Literals
Strings are texts enclosed in quotation marks:
"Hello, World!"
Quantity Literals
Quantities are like scalars but with a unit and are widely used in microcad if you wanna draw something.
4.0mm; // 4 millimeters
5l; // 5 liters
4m²; // 4 square meters
4m2; // also 4 square meters
10°; // 10 degree angle
10deg // also 10 degree angle
You will find more details about quantities and units in this section.