Modulo: Difference between revisions

142 bytes removed ,  21 May 2024
Added an example image
(Created page with "Outputs the remainder of a division calculation. File:Modulo1.png Inputs: * A: The value to be divided. * B: Value to divide A by. Output: * Mod: The remainder of the division calculation A/B. == Notes == * If the calculation doesn't have a remainder, the Modulo will be **0**. == Examples == Division: 5 / 2 = 2.5 10 / 5 = 2 Modulo: 5 % 2 = 1 10 % 5 = 0 Uses: * Do every X frames: * With the accompany of the Current...")
 
(Added an example image)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Outputs the remainder of a division calculation.
{{Block
|image=Modulo.png
|type=s
|folder=Math
|input1={{Port|n|a}}
|input2={{Port|n|b}}
|output1={{Port|n|mod(a,b)}}
}}


[[File:Modulo1.png]]
Outputs the remainder of a [[Divide|division]] calculation.


Inputs:
== Notes ==
 
* A: The value to be divided.
* B: Value to divide A by.
 
Output:


* Mod: The remainder of the [[Divide|division]] calculation A/B.
* If the calculation doesn't have a remainder, the modulo will be 0.
 
== Notes ==
* If the calculation doesn't have a remainder, the Modulo will be **0**.


== Examples ==
== Examples ==
    Division:
    5 / 2 = 2.5
    10 / 5 = 2
    Modulo:


    5 % 2 = 1
With the accompany of the [[Current Frame]] block in input A, you can specify an event that takes places every X frames. For example, because 60 frames can be converted into 1 second, input B could be 60, and when this script is run, it is going to execute it every 60th frame (a second), where the output of the modulo equals to 0.
    10 % 5 = 0


Uses:
{{Image|Modulo example1.png|Play a sound every 60 frames}}


* Do every X frames:
== Related ==
    * With the accompany of the [[Current Frame]] block in input A, you can specify an event that takes places every X frames. For example, because 60 frames can be converted into 1 second, input B could be 60, and when this script is run, it is going to execute it every 60th frame (a second), where the output of the modulo equals to 0.
   
[[File:com.martinmagni.fancade_Screenshot_2021.02.06_17.51.19.png]]


* [[Divide]]


[[Category:Blocks]]
[[Category:Blocks]]