LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to test if the remainder is a decimal or an integer?

Solved!
Go to solution

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.

0 Kudos
Message 1 of 12
(7,461 Views)

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)…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(7,455 Views)

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.

0 Kudos
Message 3 of 12
(7,427 Views)
Solution
Accepted by topic author Craster.D

@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.

0 Kudos
Message 4 of 12
(7,416 Views)
Thank you! Actually I'm a new user, so not very familiar with the options. Thanks again!
0 Kudos
Message 5 of 12
(7,397 Views)

New to LabVIEW?  Check out some free online training at the bottom of this page.

 

https://decibel.ni.com/content/docs/DOC-40451

Message 6 of 12
(7,388 Views)

"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:

  • See if there is a nonzero remainder if you divide by 1 using quotient&remainder
  • See if the output of "round to nearest" is equal to the input
  • ...

 

To do something ROR somethings else, use a case structure!

Message 7 of 12
(7,362 Views)

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!

0 Kudos
Message 8 of 12
(7,331 Views)

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. 

 

 

Message 9 of 12
(7,323 Views)

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?

0 Kudos
Message 10 of 12
(7,266 Views)