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.
a,b & D
A,B, & D
A, B, D
From benchmarks I have seen for finding an odd value, B would be the most efficient.
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.
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.
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.
a, b & D
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.
Crossrulz comment about about doing things so that the intention is readable is very important.
Probably all of these would benefit from some comment/explanation alongside them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.