Constants
Integer Constants
- An integer constant can be of decimal, octal or hexadecimal type.
- Decimal constants begin with a non-zero digit
- Octal constants begin with a zero
- Hexadecimal constants begin with "0x" or "0X"
- As a language extension, QA C also supports binary constants which are prefaced with the digits "0b" or "0B".
- An integer constant may also be appended with a suffix. The letters "u" or "U" indicating unsigned and "l" or "L" indicating type long can be applied in any order..
- Integer constants are always of type int, unsigned int, long or unsigned long. Constants of type char or short can only be constructed using a cast, e.g. "(unsigned char)0x1F"
Character Constants
- Are represented by one (or more) characters enclosed in single quote marks e.g. 'a'.
- Are implemented in type int - not type char.
- Escape sequences are of three types:
- Simple escape sequences are used to represent common control characters.
- \a alert
- \b backspace
- \f form feed
- \n new line
- \r carriage return
- \t horizontal tab
- \v vertical tab
- Hexadecimal escape sequences take the form: '\xFE8A'.
- Octal escape sequences take the form: '\015'.
Character Strings
- Are represented by a sequence of characters enclosed in double quote marks e.g. "static analysis".
- May include any member of the source character set except the double-quote ", backslash \ or new-line character.
- May include escape sequences as allowed in character constants.
Floating Constants
- Take the form of a signed non-integer number e.g. 12.74
- May also include a signed exponent e.g. 12.74E3 or 41.98E-5
- By default, floating constants are of type double.
- A constant of type float must have a suffix F or f.
- A constant of type long double must have a suffix L or l.
Index