Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

chrlum47

Member

04-08-2021 03:08 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

In the above I see how this works for integers....

How would it be entered for non-integers?

Even if I change the representation two double precision...

It still won't allow me to enter non-integers... Is there a special syntax?

Mathieu_R.

Active Participant

04-08-2021 03:24 PM - edited 04-08-2021 03:26 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hello,

Check the help about the Case Structure. I just read the following: "**Case selector**—Selects which case to execute based on the value of the input data. The input data can be a Boolean, string, integer, enumerated type or error cluster. The data type you wire to the case selector determines the allowed cases you can enter in the selector label."

So non-integer are not supported. And if you try to wire a non integer (double below), LabVIEW will coerce its value to an integer (red dot):

Hope this helps,

04-08-2021 03:28 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Yes it helps thank you..

Mathieu_R.

Active Participant

04-08-2021 03:32 PM - edited 04-08-2021 03:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

You may use additional logic, to check the value of a non-integer numeric, using the result of this intermediate logic as input for your case structure. I'm thinking about Comparison Functions and more specifically to In Range and Coerce Function

Best regards,

Kyle97330

Active Participant

04-08-2021 03:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

As said, floating point numbers can't be directly used.

However, if you want, you can get close by approximation, if your floating point numbers are guaranteed to be small enough. Instead of wiring them in directly, first multiply them by a power of 10 (say, 1000). Then choose one of the "Round" primitives, to round the number up, down, or to the nearest integer. Then wire that into the case structure. Then you can create a case like "2500..2875" that will run for any number that was originally between 2.5 and 2.875.

04-08-2021 03:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

yes thank you all posted answers are very helpful...

billko

Proven Zealot

04-08-2021 05:24 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@Kyle97330 wrote:

As said, floating point numbers can't be directly used.

However, if you want, you can get close by approximation, if your floating point numbers are guaranteed to be small enough. Instead of wiring them in directly, first multiply them by a power of 10 (say, 1000). Then choose one of the "Round" primitives, to round the number up, down, or to the nearest integer. Then wire that into the case structure. Then you can create a case like "2500..2875" that will run for any number that was originally between 2.5 and 2.875.

Also, while floating point numbers aren't directly supported, they *will* be coerced to an integer, so you can use a combo of Kyle's suggestion plus this knowledge to get you "close enough".

Bill

(Mid-Level minion.)

My support system ensures that I don't look totally incompetent.

Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

Humble author of the CLAD Nugget.

(Mid-Level minion.)

My support system ensures that I don't look totally incompetent.

Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

Humble author of the CLAD Nugget.

altenbach

Knight of NI

04-09-2021 10:45 AM - edited 04-09-2021 10:51 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

For DBL, you would typically create a 1D array diagram constant containing all range boundaries (unique and sorted), then you would threshold into it with your test value and round down/up to get an integer corresponding to each range. Now you can add a case for multiple, adjacent or nonadjacent ranges as in your first post.

*(Still you should be aware that all limitations of equal comparisons with DBL values still apply.)*

Here is an example that uses the integer to index into an array of colors. You can wire it to a case structure instead.

04-09-2021 10:49 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

excellent this post and the previous... Thank you