1.2.5. Constants

There are the following types of constant:

Integer constants

Integer constants can be in decimal, hexadecimal, octal and binary format:

  • octal constant begin with a leading 0

  • hexadecimal constants begin with the prefix 0x or 0X

  • binary numbers begin with the prefix 0b or 0B.

  • all other numbers are treated as decimal constants. Suffixes like U or L are allowed but are ignored.

String constant

A string constant is surrounded by double quotes. Special escape sequences that begin with a backslash \ can be used to include control characters into a string. See Table 1.3. To put a put a backslash into a string a double backslash \\ must be used.

Characters can also be specified using octal or hexadecimal ASCII code.

Table 1.3. Escape characters for string constants

NameEscape Sequence
horizontal tab\t
vertical tab\v
carriage return\r
form feed\f
backslash \\
question mark\?
single quote\'
double quote\"
character by octal ASCII code ooo\ooo
character by hexadecimal ASCII code hh\xhh

Boolean constants

The Boolean constants are true and false.

Double constants

A double is a floating-point number represented with 64 bits. For example: 3.14, 5.4E14, or 3E-7.

Copyright © 2007-2010 ARM. All rights reserved.ARM DUI 0371I