06-21-2017 11:39 PM
Hey Everyone! Can you please tell me what is the purpose of a remainder. Like, why do we use it? What do we get from it?
Thanks
06-21-2017 11:39 PM
Can you please tell me what is the purpose of a remainder. Like, why do we use it?
06-21-2017 11:48 PM
The Quotient and Remainder function calculates the largest integer that can be multiplied by the input value to provide a number less than the other input - this is the Quotient. The Remainder is the left-over part.
When the y input is 3, the output of the remainder (for monotonically, single increment increasing x like you get from the 'i' terminal) is 0, 1, 2, 0, 1, 2, 0, 1, 2...
This allows us to test the Remainder against 0, and that value is T, F, F, T, F, F... which allows a conditional output tunnel to output one in every 3 values.
06-22-2017 12:18 AM - edited 06-22-2017 12:29 AM
Just one example from the many, see the snippet below. But the modulo generation (my English is bad, so i am not sure about the proper terms here) is widely used in mathematics and computer science. So this "Quotient & Remainder" function is not a special LabVIEW thing, we need such functions in any computer language, etc...
Also see this wiki: https://en.wikipedia.org/wiki/Modular_arithmetic
Edit: and the naming "Frequency" is a bit misleading. Since if its value is higher, the Led will lit up less frequent 🙂 So we could call it period-length 🙂 Or you do an extra calculation step, to take a reciprocal...
06-22-2017 01:09 AM
Although I already gave this in a different thread (to the same OP 😉 ) I'll paste it here for completeness. Blokk's example gives a very detailed answer and some nice comment on the block diagram of his snippet!
The Quotient and Remainder function calculates the largest integer that can be multiplied by the input value to provide a number less than the other input - this is the Quotient. The Remainder is the left-over part. For example, 14 / 4 -> 3*4 + 2, so the Quotient is 3 and the Remainder is 2.
When the y input is 3, the output of the remainder (for monotonically, single increment increasing x like you get from the 'i' terminal) is 0, 1, 2, 0, 1, 2, 0, 1, 2...
This allows us to test the Remainder against 0, and that value is T, F, F, T, F, F... which allows a conditional output tunnel to output one in every 3 values.
06-22-2017 05:35 AM
@Blokk wrote:
But the modulo generation (my English is bad, so i am not sure about the proper terms here) is widely used in mathematics and computer science.
It is especially important in cryptography since many algorithms are based on modulo math with prime numbers as the base.
But my most common use is the "do this every X iterations" as you guys have already shown.
06-22-2017 05:57 AM
As well often used in random number generation.
https://en.m.wikipedia.org/wiki/Linear_congruential_generator