In this section we describe the ProBT variables type conversion rules in
assignments, expressions and passing of arguments. Remember that all
the data types defined by the user are internally represented either
by a plInteger
or a plFloat
. Consequently, the type
conversion process in and statement containing ProBT variables depends
on the internal types of the involved variables.
When assigning a value to a ProBT variable
the first is converted
to the type of the second. For example, consider the following lines:
wine[year] = 1987.80; wine[quality] = 3.56; wine[price] = 102.12345678901234567890; cout<<"year = "<<wine[year]<<"\n"; cout<<"quality = "<<wine[quality]<<"\n"; cout.precision(20); cout<<"price = "<<wine[price]<<"\n";
The output for year
and quality
are
year = 1987 quality = 3
the output for price
depends on the internal definition of
plFloat
. The plFloat
type can be a
float
a double
or long double
depending on the
ProBT version you have. For instance, the output we get in our PC
computer are the following:
price = 102.12345678901234568
for plFloat
long double
price = 102.12345678901235146
for plFloat
double
and,
price = 102.1234588623046875
for plFloat
float
. You can find more information
about floating-point types in the float.h
or cfloat
file
of your system, plFloat
, is defined in plMath.h
. Do not
change any information on these files otherwise you will have
compatibility problems between the library and ``.h'' files.
Combining multiple types in an expression of the form
<operand1><operator><operand2>
(where one of the operands is an ProBT variable), results in the following rule:
plFloat
the result is a plFloat
.
float
, double
or
long double
,
the result is a plFloat
.
plInteger
.
ProBT provides all the types conversions from plInteger
and
plFloat
to int
, unsigned int
,...,
long double
so that you can use ProBT variables for the passing
of parameters.