10-16-2014 09:22 PM - edited 10-16-2014 09:47 PM
Is there a way to convert an array of floating point and keep the decimals nicely as in the loop version below, but without any loop?
Solved! Go to Solution.
10-16-2014 09:47 PM
What's wrong with using a loop?
10-16-2014 10:05 PM
I think it's less efficient with big arrays.
With 2D arrays you need two Loops, 3D arrays, three loops...
I'm just wondering if there's already a way and didn't know that.
10-16-2014 11:39 PM
How about using "Array to Spreadsheet String" and "Spreadsheet String to Array" back to back.
10-17-2014 08:50 AM - edited 10-17-2014 08:53 AM
@Jimmy.chretien wrote:
I think it's less efficient with big arrays.
With 2D arrays you need two Loops, 3D arrays, three loops...
I'm just wondering if there's already a way and didn't know that.
Well, your problem as you posed it is only dealing with a 1D array for items names.
Why do you think loops would be less efficient, even for 2-D arrays and 3-D arrays? When you use Auto-indexed For Loops, LabVIEW compiles the code to be quite efficient because is knows how much space to allocated based on the size of the original array.
Even if the loops were somehow less effiicient, that really isn't going to be noticeable until your arrays happen to be many orders of magnitude larger than what you have now.
It doesn't make sense to arbitrarily limit yourself from using one of the most basic programming structures because of some perceived inefficiency. Prove to yourself you actually have a problem before you keep yourself from using the most basic of solutions.
10-17-2014 10:22 AM
Well well well OriolesFan... I benchmarked the three solutions including the one with spreadsheet proposed by P@Anand and the Loop version is arround 10X slower than the 6 fix decimals, the spreadsheet one is 2X FASTER than the loop version which is interesting when your code requires some optimization.
Cheers
10-17-2014 10:54 AM
If another solution works better for you that's great.
Before I'd claim that a solution with loops is bad and something else is 10x better, I'd be curious to see the code and the benchmarks. A true benchmark can be very difficult to do as a number of apparently insignificant settings can skew the results. Christian Altenbach here on the forums is the wizard for analyzing code, working with benchmarks, and determining what methods are the true optimums. If you'd want, I'd say post your different methods and the code you used to benchmark them.
10-17-2014 11:04 AM
10-17-2014 11:04 AM
Well, with this idea implemented, we would not even have this disucssion 😄
10-17-2014 11:08 AM
Personally, I would use a fixed number of decimal digits and right-align the strings in the control. No loop needed.. This will automatically also aling the decimal points for a clean look.