02-01-2017 02:50 PM
This one is better
02-01-2017 02:53 PM
Your bug probably has something to do with the fact that 2.8 is not exactly representable in binary floating point (e.g. DBL).
02-01-2017 02:56 PM
Sorry, uploaded the wrong file.
02-01-2017 02:57 PM
Same thing.
02-01-2017 02:58 PM
Getting the right file uploaded is harder than fixing the bug.
02-01-2017 03:17 PM
Now handles values < 1 properly (including negatives)
02-01-2017 05:06 PM
Ok, final version suitable to use as a sub-vi. I think I covered all the error handling. Still could generate a custom error code if the fraction does not resolve but I don't really think that is necessary.
02-02-2017 07:24 AM
1.33333 gives 1 3333/10000 instead of 1 1/3...
I still like the one I posted. Works with thirds, fifths, and sixths, or arbitrary list of possible denominators where the 2^n ones do not.
The XControl from paul_cardinale is awesome, but also doesn't handle thirds, returning 1 11/32 for 1.33333.
At some point I'm going to have to learn xcontrols, they look very useful. And I've run into some cases that also scream to be made into them...
02-02-2017 07:30 AM
I cleaned up the code a bit.
Note: This method doesn't handle 1/3 & 2/3 well.
02-02-2017 08:26 AM
I've imcorporated it into the XControl