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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determining whether an integer is a floating-point number

Solved!
Go to solution

I want to create a program that when an integer is input into the numeric constant, a floating-point number with all zeros to the right of its decimal point will light the LED on the front panel. The LED will remain unlit for any other floating-point number. I know I want to use a Round to Nearest function, but not sure where to go from there. 

0 Kudos
Message 1 of 4
(4,411 Views)

Hi rtufaro,

 

to put your request into a simple statement:

if number MODULO 1 == 0 then "number is integer"

LabVIEW also has a modulo operation…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(4,403 Views)
Solution
Accepted by dancer8913

@rtufaro wrote:

I want to create a program that when an integer is input into the numeric constant,


You mean CONTROL, right?

 

You just need a type of rounding.  Doesn't matter if you round up or down.  So you just round and then compare the input to the rounded value.  If they are equal, you light up your LED.  So all you need is a numeric control, 2 functions, and a boolean indicator.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(4,400 Views)

Here is basically Gerds suggestion, but in plain LabVIEW.

 

 

Note that this (AND Tim's solution above)  is only relatively safe for user-entered values. If the vaue is the result of some operations, you might run into typical issues with floating point math, so watch out for that.

0 Kudos
Message 4 of 4
(4,354 Views)