Mitsubishi QD51 Programming Manual page 544

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
SGN
Function
• Returns the sign of a value.
SGN(<numeric expression>)
Syntax
numeric expression
A=SGN(B%)
Examples
• The SGN function returns the sign of a value.
Description
• 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
30 B=0
40 C=123
50 PRINT "SGN(A)=";SGN(A)
60 PRINT "SGN(B)=";SGN(B)
70 PRINT "SGN(C)=";SGN(C)
RUN
SGN(A)=1
SGN(B)=0
SGN(C)=-1
OK
11 - 374
SiGN
• • • •
Specify the value whose sign is to be returned.
• • • •
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.
:
'Defines a numeric value
:
'Displays the result
MELSEC-Q
11 - 374

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents