User Tools

Site Tools


ch04-getting-stuff-done-i

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ch04-getting-stuff-done-i [2017/08/30 22:57]
mithat
ch04-getting-stuff-done-i [2017/09/27 23:26] (current)
mithat
Line 124: Line 124:
 Some modern languages, like Python 3, define //all// division as floating-point division by default. If you want to perform truncating division, you have to explicitly ask for it. JavaScript takes this one step further: it doesn'​t differentiate between floating-point and integer types at all; that is, in JavaScript there is only one numeric type. Some modern languages, like Python 3, define //all// division as floating-point division by default. If you want to perform truncating division, you have to explicitly ask for it. JavaScript takes this one step further: it doesn'​t differentiate between floating-point and integer types at all; that is, in JavaScript there is only one numeric type.
  
-The potential performance advantage of integer math is particularly important in real-time processes---including animations. Therefore, it's a good idea in Processing to be in the habit of not using floating-point variables and operations unless you have a good reason ​for it.+The potential performance advantage of integer math is particularly important in real-time processes---including animations. Therefore, it's a good idea in Processing to be in the habit of not using floating-point variables and operations unless you have a good reason ​to do so.
 </​WRAP>​ </​WRAP>​
  
 === Modulus === === Modulus ===
  
-TODO+The ''​%%%%%''​ operator is used for the modulus operator. The modulus operator operates on two operands that must be (or evaluate to) integer (not just numeric) values. ​ Despite appearances,​ this operation has nothing to do with percentages. The operation produces the //​remainder//​ that results from the division of the two operands. 
 + 
 +<​code>​ 
 +int x = 5; 
 +int y = 3; 
 +int z; 
 + 
 +z = x % y; 
 +</​code>​ 
 + 
 +The result of the above is that ''​%%z%%''​ holds the value 2. ((To be pedantic, there is a difference between modulus and remainder, but it only applies to negative numbers. FIXME))
  
 === Assignment === === Assignment ===
Line 148: Line 158:
 ==== Mixing numeric types ==== ==== Mixing numeric types ====
  
 +FIXME TODO
 ==== Logical operators ==== ==== Logical operators ====
  
-TODO+FIXME TODO
  
 ==== The number of operands ==== ==== The number of operands ====
Line 163: Line 174:
  
 Theoretically,​ it's possible for a language to define an operator with an arbitrary number of operands, but I am not aware of any operators that take more than three operands in Processing. Theoretically,​ it's possible for a language to define an operator with an arbitrary number of operands, but I am not aware of any operators that take more than three operands in Processing.
 +
 +----------------------------------
  
 ===== Expressions ===== ===== Expressions =====
Line 168: Line 181:
 Expressions are made of up one or more operations and return a value. Expressions are made of up one or more operations and return a value.
  
-TODO+FIXME TODO
  
 ==== Order of precedence ==== ==== Order of precedence ====
  
-TODO+FIXME TODO
  
 ==== Whitespace ==== ==== Whitespace ====
  
-TODO+FIXME TODO
  
 (Spaces, tabs, and the invisible characters that mark the end of a line. In short, whitespace in Processing (and Java, C++, and C) is interchangeable. In other words, from Processing’s point of view, a space is the same thing as a tab is the same thing as the end of a line.) (Spaces, tabs, and the invisible characters that mark the end of a line. In short, whitespace in Processing (and Java, C++, and C) is interchangeable. In other words, from Processing’s point of view, a space is the same thing as a tab is the same thing as the end of a line.)
  
  
ch04-getting-stuff-done-i.1504133864.txt.gz · Last modified: 2017/08/30 22:57 by mithat