Constants

Constants are things that don't change. Numbers are constants, like 3 or 98.

We can also have character constants that store letters of the alphabet or punctuation. We enclose these in single quotes, as in 'A', or '+'.

(If we want to indicate the single quote character, we put a backslash in front of it, as in '\''. To indicate a backslash, we put two backslashes: '\\'. We call this 'escaping' the single quote, or escaping the backslash.)

We can store strings of characters using double quotes, as in "Please push the button".

Numbers can be integers like 123, or floating point numbers, like 13.88 and 0.003.

Sometimes it is helpful to use number bases other than 10 to describe our constants.

The constant 0b111 means to set all three of the lowest bits to 1. This is the same as the decimal value 7. The 0b means the number is in binary (base 2).

We can use base 8 (called octal) by putting a zero in front of the other digits (since the 0 looks like the 'o' in octal). Thus 017 is the same as the decimal number 15.

We can use base 16 (called hexadecimal) by putting a 0x in front of the other digits, and using the letters A through F to indicate the numbers you can't express in decimal. Thus 0xA is the same as decimal 10, and 0xF is the same as decimal 15, and 0xFFFF is 16 bits that have all of the bits turned on (the same as 0b1111111111111111).