09-24-2015 10:41 AM
Hi guys!
I want to check if my remainder of two integers is a decimal or not. Also, if its a decimal, I wana use it to do one thing, and if its an integer, I want it to do something else. How can I do it?
Please help!
Thanks in advance.
Solved! Go to Solution.
09-24-2015 10:47 AM - edited 09-24-2015 10:48 AM
Hi Craster,
can you explain the operation "remainder of two integers"? Are you talking about a (math) division? This will result in a floating point number, but the result is called "quotient" usually…
Can you explain the term "is decimal or not"?
What is the difference between "decimal" and "integer"?
LabVIEW knows the MODULO operator, this will give you the remainder of Integer1 MOD Integer2. But the remainder will always be an integer…
When you use the ordinary division the remainder is either zero (easily to detect) or non-zero (between 0 and 1)…
09-24-2015 11:41 AM
Thank you for the prompt reply.
The task is to divide two numbers X and Y, and turn on an LED if the Result/Remainder is a decimal number. It may be greater or less than 1, doesn't matter. If it's not a whole number, the LED shoud turn on.
Hope I made it clear. Sorry for the ambiguity.
09-24-2015 11:45 AM
@Craster.D wrote:
The task is to divide two numbers X and Y, and turn on an LED if the Result/Remainder is a decimal number. It may be greater or less than 1, doesn't matter. If it's not a whole number, the LED shoud turn on.
Great sounds like you know exactly what you want to do, what seems to be the problem? You'll find the functions you need under the numeric, boolean, and comparision palette.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-24-2015 12:09 PM
09-24-2015 12:14 PM
New to LabVIEW? Check out some free online training at the bottom of this page.
https://decibel.ni.com/content/docs/DOC-40451
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-24-2015 01:02 PM - edited 09-24-2015 01:49 PM
"decimal" is a formatting specification and simply displays a given value using base 10 characters. All numbers can be displayed in decimal.
You are probably wondering about nonzero digits after the decimal separator.
What is the datatype of your inputs? If they are integers (blue terminals/wires) you are relatively safe as long as you stay within the valid range. If the inputs are floating point (orange terninals/wires) you might need to be a little more careful.
What is the "remainder of two integers"? if the larger is at the botton, you never have an integer. If the bottom one is zero, you don't have a valid result.
There are many ways to see if a result has a fractional part:
To do something ROR somethings else, use a case structure!
09-24-2015 02:18 PM
I'll upoad my file. All I've done so far is practice and through trial and error.
This is what I'm trying to do:
3 Numbers; A, B, C
X=AxB
Y=BxC
If X>Y, then X/Y, else Y/X. If the answer is in decimal, turn on the LED.
You guys are so supportive, thank you so much!
09-24-2015 02:28 PM - edited 09-24-2015 02:33 PM
Earlier you said the numbers are integers, so why are they orange?
The first comparison and case structure can be replaced by "Max&Min".
"decimal digits" is for strings, not numbers. I though you wanted to know if the result is an integer or contains a fractional part.
Here's a quick draft.
09-25-2015 07:22 AM
I'm new to the software. I apologise for the misuse of terminologies.
Learning to get a hold of it.
Ok, now that I have checked if the number is a decimal or not, how do I turn on the LED if it is a decimal?