LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does Labview have function Mod() ?

Solved!
Go to solution

@smercurio_fc wrote:
...Pesky mathematicians.

Makes me want to tell the jokes about how mathematicians give accurate information that is useless or makes no real sense...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 11 of 17
(3,040 Views)

@stu Turner wrote:

The "Sign" function in the Numeric palette returns a "-1" for a negative number and a "1" for a positive number. If you multiply your non-zero number by the outcome of this function, your number is returned positive and this becomes essentially a Mod[number] function.


FYI, LabVIEW does have an absolute value function in the numeric palette as well so you don't need to create one that way.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 12 of 17
(3,032 Views)

Kunsheng,

the and primitive may be your friend here. It will return 1 for every odd number an 0 for every even number.

You can also unleash it on the whole array - no iterations necessary! Smiley Happy

and.png

 

Regards Florian

0 Kudos
Message 13 of 17
(3,012 Views)

Florian, the original post is over three years old so I imagine the point is moot by now... Smiley Wink  Good point though!

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 14 of 17
(3,002 Views)

Now that you mention it. Smiley LOL

I just didn't look at the date of the original post - and from the fourth post on they're all very recent.

0 Kudos
Message 15 of 17
(2,994 Views)

When using integer maths, the better solution is to use the expression node (in the numeric functions palette).

e.g.     x%5

This is much faster than using the quotient remainder, as it is a single clock cycle (no divisions and multiplications internally).

e.g. to find odd/even integers   x%2   then have a case for 0  or not zero

Very strange that mod is not visible as a numeric function in LabView.... I guess it is a slip up by NI

0 Kudos
Message 16 of 17
(2,514 Views)

Forgot to mention:

mod  is not equivalent to remainder   (mod can give -ve results for -ve values....... ..... but remainder is always positive)

0 Kudos
Message 17 of 17
(2,511 Views)