cancel
Showing results for
Did you mean:

Active Participant

You are tasked to write a VI?

INPUT(s): Numeric an U32 Numerical Value.

OUTPUT(s): Value is Even a Boolean Value.

FUNCTION:  The VI must return TRUE if Numeric is an Even Number.

Have a go at coding the VI yourself or expand the Spoiler Tag to see the possible answers.

Spoiler
a)

b)

c)

d)

Member

a,b & D

Member

A,B, & D

Happy to Wire
Knight of NI

A, B, D

From benchmarks I have seen for finding an odd value, B would be the most efficient.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

I wrote B.  I forgot about the equal to zero block, so I checked the remainder against zero with a constant, but I basically wrote B.

What are the advantages to A or D?  They seem less efficient.

Seth Price, N3MRA
Lab Associate, Chemical Engineering Department - New Mexico Tech
Lab Assistant, Sodium Dynamo Project
Knight of NI

What are the advantages to A or D?  They seem less efficient.

A is the most direct method based on the definition of an even number (divisible by 2).  It is therefore much easier for people to understand.

D has no advantage other than it will produce the right answer.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Active Participant

For checking for an odd number, the most efficient is probably Rotate Right With Carry - the Least Significant Bit is returned directly.  Of course IsEven is easily computed from this too.  RRWC also has a benefit on an FPGA as it is purely a wiring operation so incurs no clock cycles.

Member

a, b & D

Active Participant

A, B, D

Member

Took GregS's suggestion...

This can almost be done with a single function

But checking if the value is ODD is what this really does, so needs the 'NOT' to go EVEN.