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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

conversion efficiency

Solved!
Go to solution

hi, I was a little puzzled by this question from my friend!

 

He has this for loop to create a double precison random number into an array!

 

now, he asked me which is better when he tries to convert the number into single precision number inside the loop & outside the loop!

 

aren't they both the same thing?!

 

Jay

0 Kudos
Message 1 of 4
(2,424 Views)

Hi Jay,

i think outside the loop is faster, because it's only one operation. If the function can do it, then you should use it, because it should be optimized for it.

 

Mike

0 Kudos
Message 2 of 4
(2,419 Views)
Solution
Accepted by topic author BooJay

Hi BooJay,

 

conversion in the loop: the output tunnel already creates a SGL array.

conversion outside: the tunnel creates a DBL array, which is converted as a block to SGL - thus needing another block of memory.

 

As long as memory permits you may use both methods. The conversion in the loop uses less memory, but may run slightly slower...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(2,417 Views)

cool, thanks Mike 7 GerdW,

 

I can understand why now!

Thank you so much!

 

Jay

0 Kudos
Message 4 of 4
(2,404 Views)