User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
62
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
page
mikroBasic is capable of both implicit and explicit conversion of data types.
Implicit conversion is the one automatically performed by compiler. On the other
hand, explicit conversion is performed only on demand issued by user.
This means that you can, obeying a few rules, combine simple data types with any
operators to create legal expressions and statements. Refer to Data Types if you
are not familiar with data types supported by mikroBasic.
As stated in the chapter about operators, you cannot mix signed and unsigned data
types in expressions that contain arithmetic or logical operators. You can assign
signed to unsigned or vice versa only using the explicit conversion.
- Implicit conversion takes place between byte and word, so you can com-
bine byte and word with any operators to form legal expressions.
- Implicit conversion takes place between short, integer and longint so you
can combine short, integer and longint with any operators to form legal
expressions.
- Relation operators can be used without any restraints. Smart algorithm
governing relation operators allows comparing any two data types.
- The compiler provides automatic type conversion when an assignment is
performed, but does not allow to assign signed data type to unsigned and
vice versa.
You can find more information on implicit conversion in chapters Assignment and
Implicit Conversion, and Implicit Conversion and Legal Expressions.
Explicit conversion can be executed at any point by inserting type (byte, word,
short, integer, or longint) ahead of the expression to be converted. The expression
must be enclosed in parentheses. You can't execute explicit conversion on the
operand left of the assignment operator.
page
TYPE CONVERSION
Implicit Conversion
Explicit Conversion