Jump to content

Menu Ring Matching Double Precision


JimboH

Recommended Posts

Hi all,

I am populating a menu ring (strings and values) at run time depending on another control. At times I receive values from elsewhere for the menu ring (not from selection). When I set the menu ring to the value, an unexpected behavior occurs, the display shows in brackets as when the string option is not present. This appears to be due to the values of the control and the new input value not matching as doubles out at the 20th decimal (or somewhere needlessly high). This problem seems to be fixed by switching to single precision (not shown). My main questions are, is there any way to fix this? I thought about rounding but this seemed like overkill (also that assumes that the rounding handles the same for both numbers). Really what I would like is some option that says, match values if they match when rounded out to the nth decimal place, and to have Labview take care of that in a consistent way so that, as an example, .799999999999999999 and .800000000000000000 become equal. Also, my second question is, does the behavior for single precision make sense, that it would have better luck at getting the 2 values to match? Thanks.

Jim

post-8206-1225164032.png?width=400

Link to comment

I understand the double precision comparison problem and thank you for the suggestion, I was just curious if that was exposed at all in the menu ring as it would seem that Labview might consider double precision comparison a problem and have something built in to compensate. Otherwise the suggested solution seems to be that I need to iterate through all of the values in the menu ring, find the one that is closest, and then set the menu ring to be that close value of the menu ring that nearly matches my input.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.