There are different categories of data. For instance, think about the data on an ID card. The card has numbers to store weight, height, date of birth, street address, and postal code. It has words to store a person’s name and city. There’s also image data (a photo) and often an organ donor choice, which is a yes/no decision. In Processing, we have different data types to store each kind of data. Each of the following types is explained in more detail elsewhere in the book, but this is a summary:
Name | Description | Range of values |
---|---|---|
|
Integers (whole numbers) |
−2,147,483,648 to 2,147,483,647 |
|
Floating-point values |
−3.40282347E+38 to 3.40282347E+38 |
|
Logical value |
true or false |
|
Single character |
A–z, 0–9, and symbols |
|
Sequence of characters |
Any letter, word, sentence, and so on |
|
PNG, JPG, or GIF image |
N/A |
|
Use the |
N/A |
|
SVG file |
N/A |
As a guideline, a float
number has about four digits of accuracy after the decimal point. If you’re counting or taking small steps, you should use an int
value to take the steps, and then perhaps scale it by a float
if necessary when putting it to use.
There are more data types than those mentioned here, but these are the most useful for the work typically made with Processing. In fact, as mentioned in Chapter 10, there are infinite types of data, because every new class is a different data type.