Integer

Navigation:  Language Reference > Types >

Integer

Previous pageReturn to chapter overviewNext page

Signed four-byte integer. It can hold any decimal value between -2147483648 and +2147483647. Integer is the recommended data type for the control of program loops (e.g. in for-next loops) and element numbering.

Notations

Integer values can be entered using the following notation:

 

Decimal: any combination using the symbols 0,1,2,3,4,5,6,7,8 and 9.
Binary: starting with "0b" followed by any combination using the symbols 0 and 1.
Hexadecimal: starting with "0x" followed by any combination using the symbols 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F.

 

Annotations

The value of an integer is displayed by default (e.g. in the Parameters Editor) in the decimal notation. You can use Annotations to display integers in their hexadecimal or binary notation.

Example

parameters

 integer i = 1,j = 2;

 integer B[2,2] = [1,2;3,4];

 integer x ('view=hexadecimal') = 0xE2F4;

 integer y ('view=binary') = -0b111011;

variables

 integer b;

equations

 b = B[i,j] * x * y;

Limitations

When used in standard functions, integers are treated as reals. An equation like:

 

parameters

 integer c;

equations

 c = 10*sin(time);

 

would yield c equal to 0.8415. Try to avoid these constructions, since they lead to confusions. Us the round function instead:

 

parameters

 integer c;

equations

 c = round(10*sin(time));