• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/10

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

10 Cards in this Set

  • Front
  • Back
binary()
Converts a byte, char, int, or color to a String containing the equivalent binary notation. For example, the color value produced by color(0, 102, 153, 255) will convert to the String value "11111111000000000110011010011001". This function can help make your geeky debugging sessions much happier.

Note that the maximum number of digits is 32, because an int value can only represent up to 32 bits. Specifying more than 32 digits will have no effect.

Syntax
binary(value)
binary(value, digits)
boolean()
Converts an int, string, or array to its boolean representation. For int calues, the number 0 evaluates to false and all other numbers evaluate to true.

Example
String s = "true";
boolean b = boolean(s);
if (b) {
println("The boolean is true");
} else {
println("The boolean is false");
}
byte()
Converts a primitive datatype or array to its byte representation. A byte can only be a whole number between -128 and 127, therefore when a number outside this range is converted, its value wraps to the corresponding byte representation.

Example
char c = 'E';
byte b = byte(c);
println(c + " : " + b); // Prints "E : 69"

int i = 130;
b = byte(i);
println(i + " : " + b); // Prints "130 : -126"
char()
Converts a primitive datatype or array to a numeric character representation.

Example
int i = 65;
char c = char(i);
println(i + " : " + c); // Prints "65 : A"

byte b = 65;
c = char(b);
println(b + " : " + c); // Prints "65 : A"
float()
Converts an int, string, or array to its floating point representation.

Example
int i = 65;
float f = float(i);
println(i + " : " + f); // Prints "65 : 65.0"
hex()
Converts a byte, char, int, or color to a String containing the equivalent hexadecimal notation. For example, the color value produced by color(0, 102, 153) will convert to the String value "FF006699". This function can help make your geeky debugging sessions much happier.

Note that the maximum number of digits is 8, because an int value can only represent up to 32 bits. Specifying more than 8 digits will not increase the length of the string further.

Syntax
hex(value)
hex(value, digits)

Example
color c = #ffcc00;
println(c); // Prints "-13312"
println(hex(c)); // Prints "FFFFCC00"
println(hex(c, 6)); // Prints "FFCC00"

color c = color(255, 204, 0);
println(c); // Prints "-13312"
println(hex(c)); // Prints "FFFFCC00"
println(hex(c, 6)); // Prints "FFCC00"
int()
Converts a primitive datatype, string, or array to its integer representation.

Example
float f = 65.0;
int i = int(f);
println(f + " : " + i); // Prints "65.0 : 65"

char c = 'E';
i = int(c);
println(c + " : " + i); // Prints "E : 69"
str()
Returns the string representation of primitive datatypes and arrays. For example the integer 3 will return the string "3", the float -12.6 will return the string "-12.6", and a boolean value true will return the string "true".

Example
boolean b = false;
byte y = -28;
char c = 'R';
float f = -32.6;
int i = 1024;

String sb = str(b);
String sy = str(y);
String sc = str(c);
String sf = str(f);
String si = str(i);

sb = sb + sy + sc + sf + si;

println(sb); // Prints 'false-28R-32.61024'
unbinary()
Converts a String representation of a binary number to its equivalent integer value. For example, unbinary("00001000") will return 8.

Syntax
unbinary(value)

Example
String s1 = "00010000";
String s2 = "00001000";
String s3 = "00000100";
println(unbinary(s1)); // Prints "16"
println(unbinary(s2)); // Prints "8"
println(unbinary(s3)); // Prints "4"
unhex()
Converts a String representation of a hexadecimal number to its equivalent integer value.

Syntax
unhex(value)

Example
String hs = "FF006699";
int hi = unhex(hs);
fill(hi);
rect(30, 20, 55, 55);