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.
Содержание 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...