Appendix B. Data Types

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

int

Integers (whole numbers)

−2,147,483,648 to 2,147,483,647

float

Floating-point values

−3.40282347E+38 to 3.40282347E+38

boolean

Logical value

true or false

char

Single character

A–z, 0–9, and symbols

String

Sequence of characters

Any letter, word, sentence, and so on

PImage

PNG, JPG, or GIF image

N/A

PFont

Use the createFont() function or the Create Font tool to make fonts to use with Processing

N/A

PShape

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.170.63