This seems very simple, but I feel my solution is a quick and dirty one. How would you do it?
Scenario: i have 5 integer inputs in an array (digits). I also know the location (which varies time by time) of the decimal point, so I have another input as "multiplier".
My first thought is this:
Solved! Go to Solution.
That seems to work, but it's certainly "not obvious by looking at it". This might not be as "efficient" (but who cares, unless you are doing gazillions of these), but the logic is simple -- take an array of digits, make it a number, divide by the multiplier. Given that the answer is a Float, and doing a single divide/multiply tends to avoid "float" issues, I transformed the digits into an integer string, floated it, then divided. Here's a Snippet (I apologize for it being LabVIEW 2017, which I don't generally use, but was running on a Test machine to answer another Forum question):
Bob "Simple" Schor
First i also thought about to go with number to string function, but i felt a number-string-number conversion is too much. But actually now i see that, it is more compact, much better! 🙂
another try using ASCII:
(The question was for an "elegant way", not the best performing… 🙂
I had the strong feeling, I will get lots of options, including quite "exotic" ones! 🙂
For the driver, I will use this straightforward approach, one of the solutions above. I modified it a bit, to reflect the range table values and prefixes in a more direct way. So for example, for Ohm, the largest range is xxx.xx MOhm, so the multiplier becomes 100M: