11 - 69 11 - 69
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
FIX
Function
FIX
• Returns only the integer part after truncating the fractional part of the numeric value.
FIX ( <numeric expression> )
Syntax
numeric expression
• • • •
Specify a numeric value to truncating the fractional
part.
FIX(1.28) 1
• • • •
Returns 1 after truncating the fractional part of 1.28.
Examples
FIX(-1.28) -1
• • • •
Returns -1 after truncating the fractional part of -1.28.
• The FIX function returns only the integer part after truncating the fractional part of an
integer.
• The FIX function is different from the INT function, and the fractional part is truncated by
the FIX function even if the argument (X) is negative.
• FIX(X) is equivalent to (SGN(X)) X (INT(ABS(X))).
Description
Example
X=-3.54
(SGN(-3.54)) (INT(ABS(-3.54)))
INT(absolute value 3.54)
(Sign -1) (3 after truncating the fractional part) =-3
Program Example
10 ' The fractional part of the numeric value is truncated
20 A=3.95
:
' Defines the numeric value
30 B=-3.95
40 C=FIX(A!)
:
' The fractional part of A is truncated and
stored in C
50 D=FIX(B!)
:
' The fractional part of B is truncated and
stored in D
60 PRINT " A=";A," B=";B
70 PRINT "FIX(A)=";C,"FIX(B)=";D
:
' Numeric value after the fractional part is
truncated
80 END
RUN
A= 3.95 B=-3.95
FIX(A)= 3 FIX(B)=-3
OK
REMARK
See the CINT and INT functions, Sections 2.7.1 and 2.8.1.