From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-21-2018 11:58 AM
I have 2 1D arrays of double values
I would like to convert each of them to integer values (val1=373150 val2=373146) so that I can compare which is larger. For this case val1 will be larger than val2.
12-21-2018 12:24 PM
Are there always 5 elements in the array? Are they always single digits except for the 4th value which is two digits? If so, Just to a greater than comparison and a less than comparison of the two arrays. Which ever one as the first True element from Search 1D array will be the larger.
Assuming the problem isn't that well defined. Convert the number array to a string array. Concatenate the string arrays. Convert the resulting two strings back to numbers and compare.
12-21-2018 12:26 PM
@Eth wrote:
I have 2 1D arrays of double values
I would like to convert each of them to integer values (val1=373150 val2=373146) so that I can compare which is larger. For this case val1 will be larger than val2.
I have no idea what you want to do, nor do I understand why it is difficult for you. Oh, I just "got it" -- you are concatenating the rounded-integer value of each entry (essentially "packing digits together", which is something I've never seen before (and can't imagine why you'd want to do it.
OK, as often happens, pencil and paper (or keyboard and fingers, in my case) is often a good way to start. Here is an Algorithm:
Now that you have an algorithm, code it in LabVIEW.
Bob Schor
12-21-2018 12:29 PM - edited 12-21-2018 12:32 PM
These look more like integers than DBLs.
What should happen if the number of digits differs for a pair of elements?
Can't you just compare elements (after verifying equal array size) in a loop or otherwise? Seems more reasonable.
What does the data represent, where does it come from, and what's the purpose of all this?
12-21-2018 12:38 PM
Thanks. This makes sense. I will compare each element of the array inside a loop starting with the most significant digit and determine from there which array has the largest number.
12-21-2018 01:14 PM - edited 12-21-2018 01:17 PM
If the value of each element is guaranteed to be an integer in the range 0...15, it might be a hexadecimal single digits, making a loop-free (nothing wrong with loop, though) very simple version possible.
All this assumes that the array is short. If it can be very long, more code is needed. What are the sizes?
(Sorry, posting by phone, no code example)
12-24-2018 04:50 PM - edited 12-24-2018 04:51 PM
The sizes for the first 3 positions can be from 0 to 9 and for the last 2 positions can be from 0 to 200. (both arrays can be up to 9.9.9.200.200).
12-24-2018 08:18 PM
So, if first array is 1.1.1.10.5 and the second is 1.1.1.5.10 which is supposed to be bigger?
With what you described, the second since the first is 111105 and the second is 111510.
Is that correct?
And if the first is 1.1.1.10.5 and the second is 1.1.2.1.199, is the second bigger? 111105 vs. 1121199
12-24-2018 08:48 PM
for the first 2 arrays: 1.1.1.10.5 will be larger than 1.1.1.5.10. For the other 2 arrays you got it. The second 1.1.2.1.199 will be larger. Sorry if I didn't explain what I was trying to achieve a bit more clear. I think I got the solution now. I'm converting the string arrays to DBL then I'm comparing the arrays using the 'Compare Aggregates' option. Seems to be working now. Thanks for the support!