Skip to content

Data type description

Data types are important concepts in programming languages, and they serve several purposes:

  • Memory allocation: Different data types require different amounts of memory in the computer's memory. For example, integers typically require 4 bytes of memory, while floating-point numbers may require 8 bytes or more. Therefore, using the correct data type can ensure memory usage efficiency and program performance.
  • Data processing: Different data types can support different operations and calculations. For example, integers can be used in arithmetic operations such as addition, subtraction, multiplication, and division, while strings can be used in operations such as concatenation and splitting. Using the correct data type can ensure the accuracy and effectiveness of data processing.
  • Input/output: Different data types require different input/output methods. For example, integers can be read/written using standard input/output, while images need to be read/written using specific image formats. Using the correct data type can ensure that programs can read and write data correctly.
  • Code logic: Different data types correspond to different meanings and uses, so choosing the correct data type is important in reflecting the code logic and intent.For example, boolean variables are typically used in flow control and logical judgments, while integers and floating-point numbers are typically used in mathematical calculations.

In summary, selecting and using the correct data type is a crucial step in programming, as it directly affects program correctness, performance, and maintainability. The following are the data types for Neuron:

Data typeData rangeOccupied bytesData example
INT8-128~1271For example, 100 is [0x64]
UINT80~2551For example, 100 is [0x64]
INT16-32768~327672For example, 100 is [0x64] [0x00]
UINT160~655352For example, 100 is [0x64] [0x00]
INT32-2147483648~21474836474For example, 100 is [0x64] [0x00] [0x00] [0x00] [0x00]
UINT320~42949672954For example, 100 is [0x64] [0x00] [0x00] [0x00] [0x00]
INT64-9223372036854775808~92233720368547758088For example, 100 is [0x64] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00]
UINT640~184467440737095516158For example, 100 is [0x64] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00]
FLOAT (real)-3.40E+38~+3.40E+384For example, 100 is [0x00] [0x00] [0xC8] [0x42]
DOUBLE (long real)-1.79E+308~+1.79E+3088For example, 100 is [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x59] [0x40]
BIT0/11 bitThe 0th bit of 0x11 is 1
BOOLTrue/False1 bitThe 0th bit of 0x11 is True
WORD0~655352For example, 100 is [0x64] [0x00]
DWORD0~42949672954For example, 100 is [0x64] [0x00] [0x00] [0x00] [0x00]
LWORD0~184467440737095516158For example, 100 is [0x64] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00] [0x00]

TIP

Writing a program requires an understanding of the essence of data. For example, the data essence of the number 1065353216 under the int data type is "00 00 80 3F," while the data essence of the number 1 under the float data type is also "00 00 80 3F." However, when faced with the data "00 00 80 3F," it is impossible to know what it represents. One might assume that 1065353216 is too large and must be a float value of 1, but this is a subjective judgment made by humans, and the program itself is unaware. Therefore, when interpreting data, it is important to use the same data type as the original data to avoid producing garbled output. In other words, the data should be parsed using the same data type it was originally encoded as.

About data arrangement

There is an example in the above data table. The essence of int data 100 is "64 00 00", but from our human senses, it should be "00 00 00 64", which is more reasonable. The habit of most people is to have high positions in the front and low positions in the back. However, this is only a rule. Data storage can have multiple permutations, generally divided into three types:

  • Small end arrangement: Typical representation is C # language, Mitsubishi PLC.
  • Large end arrangement: typical representative is Siemens PLC.
  • Other irregularities: Typical examples are modbus devices.

Neuron supports multiple byte orders, as shown in the following table:

ENDIAN

Byte order, applicable to int16/uint16/int32/uint32/float data types. See the table below for detailed instructions.

SymbolByte orderSupported data typesRemarks
#B2,1int16/uint16
#L1,2int16/uint16Default byte order
#LL1,2,3,4int32/uint32/floatDefault byte order
#LB2,1,4,3int32/uint32/float
#BB3,4,1,2int32/uint32/float
#BL4,3,2,1int32/uint32/float

.LEN[H][L][D][E]

When the data type is STRING, .LEN is a required entry, indicating the byte length required for a string. Each register contains four storage methods: H, L, D, and E, as shown in the following table.

SymbolDescription
HA register stores two bytes, with the high byte first and the low byte second
LA register stores two bytes, with the low byte first and the high byte second
DA register stores one byte and is stored at a low byte
EA register stores one byte and is stored in high bytes