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

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

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
CSNG
Function
• Converts an integer or a double precision real number into a single precision real number.
CSNG ( <arithmetic expression> )
Syntax
arithmetic expression
A!=CSNG(B%)
Examples
C!=CSNG(D#)
• The CSNG function converts the <arithmetic expression> value to a single precision real
Description
number with six digits of effective figures.
• An "Over flow" error occurs if the converted value is out of range of
1.7014E+38.
Program Example
10 ' Converts an integer or double precision real number into a single precision real number
20 A%=2
30 B#=1.37825432#
40 A!=CSNG(A%)
50 B!=CSNG(B#)
60 PRINT "A%=";A%,"B#=";B#
70 PRINT "A!=";A!,"B!-":B!
80 END
RUN
A%= 2
B#= 1.37825432
A!= 2
B!= 1.37825
OK
11 - 35
Convert SiNGle
• • • •
• • • •
• • • •
REMARK
• When assigning a value to the single precision variable, the type is automatically
converted into single precision if the instruction or function requires a single
precision real number as its parameter (argument).
The result of A!=3042.1545452# and A!=CSNG(3042.1545452#) will be the
same.
Specify an integer or a double precision real number
to be converted into a single precision real number.
Converts integer value B% into a single precision
real number and assigns it to A.
Converts double precision real number D# into a
single precision real number and assigns it to C.
:
' Defines the integer
:
' Defines the double precision real number
:
' Converts the integer into a double
precision real number
:
' Converts the double precision real number
into a single precision real number
:
' Value before conversion
:
' Value after conversion
MELSEC-Q
1.70141E+38 to
11 - 35

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents