LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search in a array for a negative number and replace with a zero

Solved!
Go to solution

Hello,

I want to search in a array  (double 64-bit)  for a negative number/s and replace it with a zero.

 

Br

0 Kudos
Message 1 of 8
(4,704 Views)

I would use In Range and Coerce and coerce the array to between 0 and +Inf.

Message 2 of 8
(4,702 Views)

If you don't like that suggestion (I personally do), you can always use the same brute force method used in every other programming language.

 

Quick example.png

0 Kudos
Message 3 of 8
(4,648 Views)
Solution
Accepted by topic author LVdummies

max-0.png

 

Probably the quickest option in this case 😉

---
CLA
Message 4 of 8
(4,618 Views)

@thoult wrote:

max-0.png

 

Probably the quickest option in this case 😉


That's clever!

 

I ran a benchmark on that vs the coerce method and MaxMin is about 13x faster. Kudos!

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 8
(4,601 Views)

I was curious about the time too and found it was about 20x faster using the max min. I also found that the brute force method was about 6x faster than in range and coerce.

0 Kudos
Message 6 of 8
(4,594 Views)
What the heck, I always assumed that VI must be faster than brute... Maybe it's best with some datatypes? Weird.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 8
(4,584 Views)

Sorry, I meant that the brute force is about 2x faster than in range and coerce. And the advantage does appear to go away when using I32 datatype.

 

 

0 Kudos
Message 8 of 8
(4,576 Views)