This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

sq()

Examples
example pic
noStroke();
float a = sq(1);   // Sets 'a' to 1
float b = sq(-5);  // Sets 'b' to 25
float c = sq(9);   // Sets 'c' to 81
rect(0, 25, a, 10);
rect(0, 45, b, 10);
rect(0, 65, c, 10);
Description Squares a number (multiplies a number by itself). The result is always a positive number, as multiplying two negative numbers always yields a positive result. For example, -1 * -1 = 1.
Syntax
sq(n)
Parameters
n float: number to square
Returnsfloat
Relatedsqrt()
Updated on May 19, 2014 05:29:59pm PDT

Creative Commons License