Int([expr]), Sgn([expr]), Sqr([expr]) – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 32

Advertising
background image

Publication 1746-RM001A-US-P

3-10 Expressions and Operators

INT([expr])

Use the INT operator to return the integer portion of the expression.

PI

PI is a stored constant. In the module PI is stored as 3.1415926.

SGN([expr])

Use the SGN operator to return a value of +1 if the argument is greater than zero,
zero if the argument is equal to zero, and –1 if the argument is less than zero.

SQR([expr])

Use the SQR operator to return the square root of the argument. The argument
may not be less than zero.

Example

Result

>PRINT INT(3.7)

3

>PRINT INT(100.876)

100

Example

Result

>PRINT SGN(52)

1

>PRINT SGN(0)

0

>PRINT SGN(–8)

-1

Example

Result

>PRINT SQR(9)

3

>PRINT SQR(45)

6.7082035

>PRINT SQR(100)

0

Advertising