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
Last revision Both sides next revision
ch04-getting-stuff-done-i [2017/08/30 22:57]
mithat
ch04-getting-stuff-done-i [2017/08/30 23:11]
mithat [Expressions]
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 ====
  
 +TODO
 ==== Logical operators ==== ==== Logical operators ====
  
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 =====
ch04-getting-stuff-done-i.txt · Last modified: 2017/09/27 23:26 by mithat