08-29-2013 12:58 PM
Is there a built-in way to convert a integer-fraction notation (enterd by a user on FP) to it's approximate double precision value?
For instance, if the user types "1", then the double precision value is simply 1, if they type "1 11/16" then the value would be interpreted as 1.6875. By default, labview ignores non-numeric data entered into a numeric control so typing "1 11/16" does nothing.
I know I could brute force this by using a string control, testing for a space after the first integer and parsing out the numbers before and after a "/" or "\" ...and so on, but I was wondering if there is an easier way, more elegant way to handle this.
Solved! Go to Solution.
08-29-2013 02:23 PM
Well a double is a real, while "1 16/17" is a rational number. So any double can't be expressed the way you want? And is it really that undignified to make a subVI that does the job?
08-29-2013 02:34 PM
08-29-2013 02:43 PM
I would make a cluster with whole numers, numerators and denometer (probably an enum) and handle a value change on teh cluster and turn it into a double. No easy button that I know of. I think the cluster of 2 ints and an enum would have the least bounds checking.
08-29-2013 04:06 PM
... use an ActiveX interface to EXCEL? EXCEL accepts input like =1 + 11/16 and computes it properly. It's a matter of taste if you want to call such an approach more elegant.
Cheers
Edgar
08-29-2013 04:40 PM
Simple minute implementation.
Very crude.
Could add tabing, and events and bounds checking. Should make a typdef and add functions for this typdef.
08-29-2013 05:05 PM
I like that this is safe, i.e. can't divide by 0 and relatively light weight. I can make it look and feel a little prettier, thanks for idea.
08-30-2013 01:56 AM
08-30-2013 08:15 AM
fractional input might be a nice idea to add to the forum if not already there.
08-30-2013 11:39 AM
Yes, i'm sure it's a fairly common "want to have" but I guess most people just work around it by either memorizing the equivalent decimal input or using an intermediate tool (calculator or printed look up table). I couldn't believe no results came up when I searched before making this post.