JimboH Posted October 29, 2008 Report Share Posted October 29, 2008 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 Quote Link to comment
MikaelH Posted October 29, 2008 Report Share Posted October 29, 2008 When comparing two float values you have to use this VI: ... but unfortunate this VI don't exists ;-) I have a VI looking like this to solve the problem: Cheers, Mikael Quote Link to comment
crelf Posted October 30, 2008 Report Share Posted October 30, 2008 QUOTE (MikaelH @ Oct 28 2008, 06:28 PM) I have a VI looking like this to solve the problem: Looks like a candidate for OpenG, although it might be better implemented using "In Range and Coerce". I'd like to see it also compare based on a % of the first input. Quote Link to comment
JimboH Posted October 30, 2008 Author Report Share Posted October 30, 2008 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.