Cint ( Converts A Single Precision Real Number Or A Double Precision Real Number Into An Integer ) - Mitsubishi QD51 Programming Manual

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

Advertisement

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

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents