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
262
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:
esProc Getting Started: Basic Data Types - Image 1
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:
esProc Getting Started: Basic Data Types - Image 2

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.
esProc Getting Started: Basic Data Types - Image 3
Values of A1, A2, A3 and A4 are as follows:
esProc Getting Started: Basic Data Types - Image 4

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.
esProc Getting Started: Basic Data Types - Image 5
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:
esProc Getting Started: Basic Data Types - Image 6

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 :
esProc Getting Started: Basic Data Types - Image 7
Values of A1, A2, A3 and A4 are as follows:
esProc Getting Started: Basic Data Types - Image 8

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.
esProc Getting Started: Basic Data Types - Image 9
Values of A1, A2 and A3 are as follows:
esProc Getting Started: Basic Data Types - Image 10

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.
esProc Getting Started: Basic Data Types - Image 11
Values of A1, A2 and A3 are as follows:
esProc Getting Started: Basic Data Types - Image 12
Click Tool->Options menu item, and set the format of time/date data and the character code, etc. on the Environmenttab.
esProc Getting Started: Basic Data Types - Image 13

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
esProc Getting Started: Basic Data Types - Image 14
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:
esProc Getting Started: Basic Data Types - Image 15
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:

esProc Getting Started: Basic Data Types - Image 1

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:

esProc Getting Started: Basic Data Types - Image 2

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.

esProc Getting Started: Basic Data Types - Image 3

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

esProc Getting Started: Basic Data Types - Image 4

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.

esProc Getting Started: Basic Data Types - Image 5

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:

esProc Getting Started: Basic Data Types - Image 6

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 :

esProc Getting Started: Basic Data Types - Image 7

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

esProc Getting Started: Basic Data Types - Image 8

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.

esProc Getting Started: Basic Data Types - Image 9

Values of A1, A2 and A3 are as follows:

esProc Getting Started: Basic Data Types - Image 10

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.

esProc Getting Started: Basic Data Types - Image 11

Values of A1, A2 and A3 are as follows:

esProc Getting Started: Basic Data Types - Image 12

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

esProc Getting Started: Basic Data Types - Image 13

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

esProc Getting Started: Basic Data Types - Image 14

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:

esProc Getting Started: Basic Data Types - Image 15

This blog is listed under Development & Implementations and Data & Information Management Community

Related Posts:
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top