Processing requires explicit data types — int, float, and boolean serve different numeric purposes
Processing is a typed language: every variable must be declared with a data type. int stores whole numbers (no decimal); float stores decimal numbers (up to ~7 significant digits); boolean stores true or false. Integer division truncates: 4/3 = 1, not 1.333. Assigning a float result to an int variable is a compile error unless you explicitly cast. The system variables width and height are read-only ints set by size(). A common mistake is dividing two int variables expecting a float result — at least one operand must be written as a float (e.g., 4.0/3 gives 1.3333334).
Examples
int a = 4/3; // assigns 1 (integer division truncates) float b = 4.0/3; // assigns 1.3333334 float c = 4/3; // assigns 1.0 (division happens first as int)
Assessment
Predict the value of: (a) int x = 7/2; (b) float y = 7/2; (c) float z = 7.0/2. Explain why (b) and (c) differ.