OSCAT BASIC ArithmeticsDoublePrecision - RWTH-EBC/AixOCAT GitHub Wiki
8. Arithmetics with Double Precision
8.1. Introduction
Floating point numbers are stored in the format REAL. A common data for-
mat according to IEC754 used a 24 bit wide mantissa and an 8-bit expo-
nent. This results in an accuracy of 7-8 digits. Usually this is for applicati-
ons in control technology more than sufcient, but in certain cases can
lead to a problem. A typical case can which be solved with single-precision
only inadequate is a consumption meter. If you want to several Mwh (me-
gawatt hours) of total consumption adding up, taking a smallest power of
1 mW (milliwatt) at a distance of 10ms fairs and so you need a resolution
of 3.6 * 10^7 (equivalent 10MWs) and it would be a do add up 1* 10^-5
W's. To do this it requires a resolution of 12 digits.
The solution implemented by OSCAT is REAL Double precision and has a
resolution of about 15 digits. The implemented data type REAL2 consists
of R1 and RX, RX is here the value saved the frst 7-8 points as Real and
the rest in one real R1. This data type has the advantage that no conversi-
on of REAL2 to REAL is needed, rather, the RX is rather part of single REAL
value.
8.2. R2_ABS
Type Function: REAL2
Input X: REAL2 (Input)
Output REAL2 (result double-precision)
R2_ABS returns the absolute value of x in double precision.
8.3. R2_ADD.
Type Function: REAL2
Input X: REAL2 (Input)
Y: REAL (value to be added)
Output REAL2 (result double-precision)
R2_ADD adds to a double-precision value X is a single-precision value Y.
The result has again double precision.
8.4. R2_ADD2.
Type Function: REAL2
Input X: REAL2 (Input)
Y: REAL2 (value to be added)
Output REAL2 (result double-precision)
R2_ADD2 adds to a double precision value X to another double-precision
value Y. The result has again double precision.
8.5. R2_MUL.
Type Function: REAL2
Input X: REAL2 (Input)
Y: REAL (multiplier)
Output REAL2 (result double-precision)
R2_MUL multiplies a double precision value X with a single-precision Y. The
result has again double precision.
8.6. R2_SET
Type Function: REAL2
Input X: REAL (Input)
Output REAL2 (result double-precision)
R2_SET sets a double precision value to the input value x with single preci-
sion.