MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.

I'm not curious

# esProc Getting Started: Basic Data Types

Published on 16 October 14
0
0

1.Data types in esProc

In esProc, the following basic data types are available:

Integer

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.

Long 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: Since the value range of common integers is -231~231-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 -263~263-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. 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 bigdecimal. 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 : Values of A1, A2, A3 and A4 are as follows: String

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. 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. 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 Environmenttab. 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 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: This blog is listed under Data & Information Management Community

Related Posts:

## Data Type

You may also be interested in
Mario Lewis

on 23 October 20
Dana

on 23 January 19
Ray

on 31 December 18
Seashore

on 12 October 18
Jenny

on 15 September 18  