11 - 23 11 - 23
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
CINT
Function
Convert INTeger
• Converts a single precision real number or a double precision real number into an integer.
CINT ( <arithmetic expression> )
Syntax
arithmetic expression
• • • •
Specify a single precision real number or a double
precision real number to convert into an integer.
A%=CINT(B!)
• • • •
Converts a single precision real number B! into an
integer and assigns it to A%.
Examples
C%=CINT(D#)
• • • •
Converts a double precision real number D# into an
integer and assigns it to C%.
Description
• The CINT function converts the value of <arithmetic expression> into an integer value and
returns the maximum integer that does not exceed the value of <arithmetic expression>.
• The fraction part is rounded down if a positive value is specified, and the fraction part is
rounded up if a negative number is specified.
Example
5.689
1.031
2.999
5
1
2
-3.84
-1.2639
-1.9999
-4
-2
-2
• An “Over flow” error occurs if the result value is out of the range of 32768 to 32767.
Use the INT function to convert a value over 32768 into an integer value.
Program Example
10 ' Converts a single precision or a double precision real number into an integer
20 A!=7.15
:
' Defines a single precision real number
30 B#=1.598421#
:
' Defines a double precision real number
40 A%=CINT(A!)
:
' Converts a single precision real number to
an integer
50 B%=CINT(B#)
:
' Converts a double precision real number
to an integer
60 PRINT "A!=";A!,"B#=";B#
:
' Value before conversion
70 PRINT "A%=";A%,"B%=";B%
:
' Value after conversion
80 END
RUN
A!= 7.15
B#= 1.598421
A%= 7
B%= 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...