Hardware Reference
In-Depth Information
character constant is represented by the ASCII code of the character. A string constant is a se-
quence of zero or more characters surrounded by double quotes, as in
“HCS12DG256 is a microcontroller made by Freescale”
or
“” /* an empty string */
Each individual character in the string is represented by its ASCII code.
An integer constant such as 3241 is an int . A long constant is written with a terminal l
(lowercase letter “el”) or L, as in 44332211L. The following constant characters are predefined
in C language (can be embedded in a string):
\a
alert (bell) character
\\
backslash
\b backspace
\?
question mark
\f form feed
\'
single quote
\n
new line
\”
double quote
\r
carriage return
\ooo
octal number
\t horizontal tab
\xhh hexadecimal number
\v vertical tab
As in assembly language, a number in C can be specified in different bases. The method
to specify the base of a number is to add a prefix to the number. The prefixes for different
bases are
Base
Prefix
Example
decimal
none
1357
octal
0
04723
; preceded by a zero
hexadecimal
0X
0X2A
5.3.4 Arithmetic Operators
There are seven arithmetic operators.
1 add and unary plus
2 subtract and unary minus
* multiply
/ divide
% modulus (or remainder)
11 increment
22 decrement
The expression
a % b
produces the remainder when a is divided by b . The % operator cannot be applied to fl oat or
double. The 11 operator adds 1 to the operand, and the 22 operator subtracts 1 from the op-
erand. The / operator performs a division and truncates the quotient to an integer when both
operands are integers.
 
Search WWH ::




Custom Search