1.Data types in esProc
In esProc, the following basic data types are available:
Any integer between -231 and 231-1, i.e. the value range is -2147483648~2147483647.The type conversion function int()can be used to convert other types of data into integer.
-263~263-1, which is a value range bigger than that for integer type. The type conversion function long()can be used to convert other types of data into long integer.Long integer can be specially represented by appending a capital letter L to the integer. Compared with an integer, a long integer has a bigger value range; strings starting with 0x can be used to represent the hexadecimal long integers:
As can be seen from the computed results of A1 and A3, if one of the operands involved is a long integer during the operation of a certain step, the result will be a long integer.
Floating-point number64-bit floating-point number is the commonest data type in esProc. Almost all decimals-related computations are performed with this data type. The type conversion function float() can be used to convert other types of data to floating-point number. Because the floating-point number is used to store data according to the binary rule, there could be errors in the computation.
The floating-point number in A2 is represented by scientific notation; A3 contains a floating-point number represented by a percentage, which, with this writing form, can only be used as a constant instead of being used in an expression.
Big decimalBig decimal can be used to store any real number error-freely, but more memory could be consumed when big decimal is used for computation and the computational efficiency is relatively low. The type conversion function decimal() can be used to convert other types of data (such as the string)into the bigdecimal.
It can be seen that the operation using a floating-point number that works according to the binary rule could result in accuracy errors, while the operation using a big decimal is much more accurate.
The real number covers four data types: integer, long integer, floating-point number and big decimal. number()is the type conversion function available to convert other types of data to real number.
BooleanIt includes true and false :
Double quoted in an expression, and the right slash \ is used as the escape character. If the string is defined in a constant cell directly, the double quotation marks are omitted.string() function can be used to convert other types of data to strings. When concatenating two strings x and yin an expression, you can add a space between them, that is, xy.The escape rule of strings is the same as that of JAVA. For details, please refer to the manual.
DatetimeWritten in the format of yyyy-mm-dd and hh:mm:ss.Type conversion functions such as date(), time() and datetime() can be used to convert the string or long integer to date, time, or datetime.
Precision may be sacrificed when a type of data is converted into another one.
2. Judge the data type
The type of data can be judged with the following functions:
Judge if x is a real number
Judge if x is a string
Judge whether x is a date or a datetime
iftime(x)Judge if x is a time