11 - 374 11 - 374
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
SGN
Function
SiGN
• Returns the sign of a value.
SGN(<numeric expression>)
Syntax
numeric expression
• • • •
Specify the value whose sign is to be returned.
Examples
A=SGN(B%)
• • • •
Assigns 1 to A if the value of B% is positive, 0 to A if
the value of B% is 0, and -1 to A if the value of B% is
negative.
Description
• The SGN function returns the sign of a value.
• It returns 1 if the value of <numeric expression> is positive, 0 if it is 0, and -1 if it is
negative.
Program Example
10 ' This program returns the sign of a value
20 A=-123
:
'Defines a numeric value
30 B=0
40 C=123
50 PRINT "SGN(A)=";SGN(A)
:
'Displays the result
60 PRINT "SGN(B)=";SGN(B)
70 PRINT "SGN(C)=";SGN(C)
RUN
SGN(A)=1
SGN(B)=0
SGN(C)=-1
OK
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...