From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-25-2009 04:02 PM
hello,
How can i find out whether a given number ( a variable after simplification holds a value) is an integer or not.?
I thought i could use isinteger( ) function in mathscript, but it does not exist- is giving error
can i do it without mathscript?
Thanks,
Solved! Go to Solution.
01-25-2009 04:27 PM
In LabVIEW, an integer has a blue wire and terminals.
You probably want to know if a floating point number (orange wire) is an integer or not.
This can be very tricky, because if the value is the result of some computations, it could be off by a few bits. You probably want to test instead if the value is "sufficiently close" to an integer.
If you don't care about possible complications (however you really should!!!), you could use quotient&remainder to divide by 1 and see if the remainder is zero. You could also compare the original value with the same value fed across "round to nearest" and see if they are equal.
Can you explain in a bit more details what you are actually trying to do, e.g. with an example?
01-25-2009 05:11 PM
01-25-2009 05:16 PM
well, the equation i am trying to solve is f = ( m/N)*fs,
where fs - sampling frequency , f is the analog frequency and N - no of points.
m should be a integer for correct sampling. so i have to check whether for a given fs, as i vary f, m is an integer or not,
if not, i have to round it the nearest integer.
so, basically there are two requirements - find out if it is an integer, if not, round it of..
Many thanks.
01-25-2009 05:30 PM
Can't you just make "m" an integer data type?
-D
01-25-2009 06:47 PM - edited 01-25-2009 06:47 PM
I assume you want m/N to be a (possibly rounded up) integer. Is this correct.
In this case, you could do something like the following?
01-25-2009 07:03 PM
01-26-2009 12:22 PM
altenbach,
as you had said earlier, i tried dividing the number by 1 ( making 1 as an integer - i.e blue wire )- then find if remainder is 0 or not.
to round it - i used conversion to U32 or U16.
This seems to be working.
But should it not have type casted the int ( blue wire ) to float (orange) before dividing.?
Thanks..
01-26-2009 01:04 PM
01-26-2009 01:17 PM
rebelstar wrote:But should it not have type casted the int ( blue wire ) to float (orange) before dividing.?
Quoteient&rmainder works natively on integers as well as floating point. No need to convert. Simply make sure that the two inputs match. For example don't use an orange "1" if the upper input is blue. Make the diagram constant the same representation as the other input. Look at the picture I attached earlier. No coercion dots.