This page has no translation to 中文 yet. The original English version is below. If you’d like to help, great! See how to translate a documentation page in the contribution guide.

Data Types Reference

This reference briefly describes properties of built-in XOD types. To learn about the types see Data types guide.

Color code #

Color code

Casting rules #

The following table shows implicit casts possible. That is, when a direct link between two various data types is valid. Even if the direct link is forbidden, there are nodes that help to convert between types explicitly.

→ Pulse → Boolean → Number → Byte → Port → String
Pulse → no no no no no
Boolean → yes yes yes no yes
Number → no yes no no yes
Byte → no yes no no yes
Port → no no no no yes
String → no no no no no

Here are details on how the data is transformed exactly when an implicit cast takes place.

From To How
Boolean Pulse Rising edge is considered to be a pulse. That is when the value was False and just became True a single pulse is emitted.
Boolean Number False converts to 0.0 and
True converts to 1.0.
Boolean Byte False converts to 0000 0000 and
True converts to 0000 0001.
Boolean String True converts to "true" and
False converts to "false".
Number Boolean Zero converts to False,
any other value converts to True.
Number String Converts with two digits after decimal, e.g. 3.14159 → "3.14" and 0 → "0.00".
Byte Boolean 0000 0000 converts to False,
any other value converts to True.
Byte String Converts as a two-digit hexadecimal number with h-suffix, e.g. 0000 11010Dh.
Port String Converts port as it shown in the XOD IDE. D13"D13" and A3"A3".

Literals #

This section summarizes valid text input (i.e., grammar) for various data types. It matters, for example, when you enter values in IDE with Inspector.

Number literals #

Literal Comment
1000 In the basic case of integer number, the literal is a sequence of decimal digits
+1000 It may include an explicit sign
-1000 Be negative
-1000.45 Include a fraction after decimal dot
-.45 If the integer part is zero it may be omitted
1000. Trailing decimal dot is allowed
2e6 A literal can have a decimal exponent after “e” character (2×106 = 2 000 000)
2e+6 The exponent can have a sign
2e-6 An be negative (2×10-6 = 0.000002)
+.2e-3 Rules for the part before “e” still apply
Inf A special value to denote the positive infinity
+Inf Can include explicit sign
-Inf Or be a negative infinity
NaN The “Not A Number” value to signal about an operation error

Boolean literals #

Valid literals are:

  • True
  • False

In some inputs IDE or CLI can normalize almost valid literals like lower-cased true or false, however the canonical form is as shown.

Byte literals #

Literal Comment
1Ah The canonical hexadecimal form contains two digits (0-9|A-F) followed by h-suffix
03h Values less than 10h should have the leading zero
00011010b In the binary form the literal is eight digits (0|1) followed by b-suffix
26d The decimal form contains an integer in range [0; 255] followed by d-suffix
006d The leading zeros are allowed but may be omitted
'a' A character surrounded by single quotes is translated to a byte value equal to its ASCII code
'\n' A backslashed character specifies a control ASCII character like line feed, carriage return, tab, etc

In some inputs IDE or CLI can normalize almost valid literals like 3h (no leading zero), 0x03 (customary hexadecimal for C++, JavaScript, and Python programmers), 3 (implied decimal 3), however the canonical form is as shown.

Port literals #

Literal Comment
D4 Digital port values start with “D” followed by the actual port number
A6 Analog ports/channels start with “A” followed by the number

Note that analog port values can be converted to digital port values, but not vice versa. So, in cases when an analog channel and a digital port share the same physical board pin (e.g., A6 and D4 on Arduino Leonardo) you must choose A6 for ADC reading, albeit for digital operations either will be suitable: A6 will be coerced to D4 by the runtime engine.

String literals #

Literal Comment
"Hello" String literals are allways enclosed in double quotes
"Dist: 10\"" If a string contains " itself, it should be escaped by \ (Dist: 10")
"Hello\nWorld" A new line is encoded as \n sequence
"Hello\r\nWorld" \r encodes carriage return
"1023.0\t244\t1" \t encodes TAB symbol
"A\\B\\C" Backslashes are escaped by backslashes (A\B\C)

Pulse literals #

Literal Comment
Never Literally never emit a pulse there
On Boot Emit a pulse once at the program start
Continuously Emit pulses as fast as performance allows, in each transaction

Color literals #

Values for xod/color/color type can be entered in #RRGGBB format. There, RR is amount of Red (using two hexadecimal digits), GG is amount of Green, and BB is amount of Blue.

For example, #00BFFF will be displayed as a light blue color.

Found a typo or mistake? Want to improve the text? Edit this page on GitHub and open a pull request. If you have a complex proposal or you want to discuss the content, feel free to start a new thread on XOD forum.