DL205 User Manual, 4th Edition, Rev. B
5–263
Chapter 5: Intelligent Box (IBox) Instructions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A
B
C
D
Real to BCD with Implied Decimal Point and Rounding (RTOBCD) (IB-561)
Real to BCD with Implied Decimal Point and Rounding converts the absolute value of the
given Real number to a 4-digit BCD number, compensating for an implied number of
decimal points (K0-K4) and performs
rounding.
For example, RTOBCD R56.74 with an
implied number of decimal points equal to
K1, would yield 567 BCD. If the implied
number of decimal points was 0, then the
function would yield 57 BCD (note that it
rounded up).
If the Real number is negative, the Result will
equal its positive, absolute value.
RTOBCD Parameters
• Value (DWORD Real): specifies the Real Dword location or number that will be converted and
rounded to a BCD number with decimal points
• Number of Decimal Points: specifies the number of implied decimal points in the Result WORD
• Result (WORD BCD): specifies the location where the rounded/implied decimal points BCD value
will be placed
RTOBCD Example
In the following example, the RTOBCD instruction is used to convert the 32-bit REAL
(floating point) data format in V3000 and V3001 to the 4-digit BCD data format and store
in V2000 when C100 turns on.
K2 in the Number of Decimal Points implies the data will have two implied decimal points.
Parameter
DL205 Range
Value (DWORD Real) . . . . . . . . . . . . . . . . . V,P,R
R ; See DL205 V-memory map - Data Words
Number of Decimal Points . . . . . . . . . . . . . . . K
K0-4
Result (WORD BCD) . . . . . . . . . . . . . . . . . . . . . V
See DL205 V-memory map - Data Words
DS5 Used
HPP
N/A
ý
ý
þ
þ
230
240
2
5
0
-1
2
6
0