next up previous contents
Next: String Literals Up: Numeric Literals Previous: Numeric Literals

Example: Numbers

Let's take a look at some different types of numbers that you can use in your program code.

First, here are some integers.

An integer. Integers are numbers with no decimal components. An integer in octal format. This number is 35, or (4 * 8) + 3, in base 10. An integer in hexadecimal format. This number is also 35, or (2 * 16) + 3 in base 10.

123
043
0x23

Now, some numbers and fractions-also called floating point values. You will frequently see these values referred to as a float value for simplicity's sake.

A float with a value in the tenths place. You can also say 100 and 5/10.A float with a fraction value out to the thousandths place. You can also say 54 and 534/1000.

100.5
54.534

Here's a very small number.

A very small float value. You can represent this value in scientific notation as 3.4E-5.

.000034



dave@cs.cf.ac.uk