Implicit type conversion: Difference between revisions

Content added Content deleted
(Added XPL0 example.)
Line 1,725: Line 1,725:
var b3 = b1 + b2 + 2 + "2"
var b3 = b1 + b2 + 2 + "2"
System.print(b3) // 100</syntaxhighlight>
System.print(b3) // 100</syntaxhighlight>

=={{header|XPL0}}==
XPL0 doesn't have implicit type conversions. It only has two basic data
types: integer and real. Conversions must be done explicitly. For
example:
<syntaxhighlight lang "XPL0">
int I;
real R;
I:= fix(R);
R:= float(I);
</syntaxhighlight>

There is a third declaration type called 'character' (usually abbreviated
'char'). Its variables are the same as integers except when they are
indexed, as for arrays. An indexed character variable accesses bytes,
whereas an indexed integer variable accesses integers.

Strings are one-dimensional arrays consisting of bytes containing ASCII
characters.

Booleans are represented by integers. Zero is false, and non-zero is
true.

Real literals are distinguished from integers by including a decimal point or exponent. For example: 12. or 6e12


=={{header|Z80 Assembly}}==
=={{header|Z80 Assembly}}==