## 1. Data types in esProc

In esProc, the following basic data types are available:

**Integer**

Any integer between -2^{31} and 2^{31}-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.

**Long integer**

-2^{63}~2^{63}-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:

A | |

1 | =123456789L*1000 |

2 | =123456789*1000 |

3 | =12345678900*10 |

4 | 0x00FF |

Since the value range of common integers is -2^{31}~2^{31}-1, that is, -2147483648~2147483647, the result in A2 is beyond the boundary. While by using a long integer in A1, the value range is increased to -2^{63}~2^{63}-1 and correct result can be obtained. In A3, the number 12345678900 is beyond the value range of common integers and will be parsed automatically into a long integer. It is a hexadecimal constant that cell A4 contains. Values of A1, A2, A3 and A4 are as follows:

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 number**

64-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.

A | |

1 | 43.41 |

2 | -4.45E13 |

3 | 3% |

4 | =float(54) |

Values of A1, A2, A3 and A4 are as follows:

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 decimal**

Big 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 big decimal.

A | |

1 | 5.2 |

2 | =A1*A1 |

3 | =decimal(“5.2”) |

4 | =A3*A3 |

The 5.2 in A1 is a floating-point number; the code in A3 converts the string “5.2” into a big decimal. The computed results in A2 and A4 are as follows:

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.

**Real number**

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.

**Boolean**

It includes true and false

A | |

1 | true |

2 | false |

3 | =4>2 |

4 | =13%3==0 |

Values of A1, A2, A3 and A4 are as follows:

**String**

It needs to be double quoted and escaped by the right slash \ in an expression. If the string is defined as a constant directly, the double quotation marks are not needed. string() function can be used to convert other types of data to strings. When concatenating two strings x and y in an expression, you can add a space between them, that is, **x** **y**; or just add them up like ** x+y**.

**This requires that both**. In this way, if one of them is a real number, the result will be a real number, rather than a string. To concatenate a real number with a string as concatenating two strings, you can use

*x*and*y*are strings**, whose result will be a string – as long as one of the operands is a string.**

*x*/*y*The esProc rule of escaping strings is the same as that of JAVA. For details, please refer to the Tutorial.

A | |

1 | Amy |

2 | =”State:\tTX” |

3 | =”Texas” “Dallas” |

4 | =A1+3.14 |

5 | =A1/3.14 |

Values of A1, A2 and A3 are as follows:

**Datetime**

Written 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.

A | |

1 | 2014-10-5 |

2 | 22:15:30 |

3 | =date(“2014” “-10” “-5”) |

Values of A1, A2 and A3 are as follows:

Click **Tool** ->** Options** menu item, and set the format of time/date data and the character code, etc. on the** Environment** tab.

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:

**ifnumber(x)**

Judge if x is a real number

**ifstring(x)**

Judge if x is a string

**ifdate(x)**

Judge whether x is a date or a datetime

**iftime(x)**

Judge if x is a time

A | |

1 | =ifnumber(3.5) |

2 | =ifstring(now()) |

In A1, the floating-point number 3.5 is a real number. **now()** function in A2 computes the current date and time and the resut is not a string. The results in A1 and A2 are as follows: