Mikroelektronika MIKROE-350 Fiche De Données
LITERALS
Literals are tokens representing fixed numeric or character values.
The data type of a constant is deduced by the compiler using such clues as numer-
ic value and format used in the source code.
ic value and format used in the source code.
Integer Literals
Integral values can be represented in decimal, hexadecimal or binary notation.
In decimal notation, numerals are represented as a sequence of digits (without com-
mas, spaces or dots), with optional prefix + or - operator to indicate the sign. Values
default to positive (
mas, spaces or dots), with optional prefix + or - operator to indicate the sign. Values
default to positive (
6258
is equivalent to
+6258
).
The dollar-sign prefix (
$
) or the prefix
0x
indicates a hexadecimal numeral (for
example,
$8F
or
0x8F
).
The percent-sign prefix (
%
) indicates a binary numeral (for example,
%0101
).
Here are some examples:
11 ' decimal literal
$11 ' hex literal, equals decimal 17
0x11 ' hex literal, equals decimal 17
$11 ' hex literal, equals decimal 17
0x11 ' hex literal, equals decimal 17
%11 ' binary literal, equals decimal 3
The allowed range of values is imposed by the largest data type in mikroBasic PRO
for AVR –
for AVR –
longword
. The compiler will report an error if the literal exceeds
4294967295
(
$FFFFFFFF
).
Floating Point Literals
A floating-point value consists of:
- Decimal integer
- Decimal point
- Decimal fraction
- e or E and a signed integer exponent (optional)
- Decimal point
- Decimal fraction
- e or E and a signed integer exponent (optional)
You can omit either decimal integer or decimal fraction (but not both).
Negative floating constants are taken as positive constants with the unary operator
minus (-) prefixed.
minus (-) prefixed.
114
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5