LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between a I8 I16 I32 Zero

I can only suggest but does it make a difference if I am using a i8-constant (e.g. 1,2,3,...255) as a DBL. For example does LabView adapt constants which are i8 and represented as i16,sgl or dbl for saving memory?

The most trivial example is the zero. Is a i8 zero = i16 zero = dbl zero = sgl zero =....a.s.o.

It is a simple question but confusing me 😉 So thx for help.
0 Kudos
Message 1 of 6
(6,064 Views)
There is no functional problem with overclassifying your datatypes. If you only NEED the precision of I8, but you are using a DBL, the function will be the same (assuming you don't use floating points).
 
The drawback to using a classification that is more precise than necessary is memory usage, of course. The difference is slight, but in large programs the accumulated waste of memory can be significant.
 
Labview assigns I32's and DBL's to almost anything automatically generated. Labview is just plunking in the value so the your app will be as versatile as possible. It will be up to the programmer to reduce the precision wherever feasible.
 
The book of proper technique will teach you that you should use the lowest level of precision required for each variable, if for no other reason- to save memory.
 
And yes, a zero is a always a zero, regardless of precision.

Message Edited by RWiersma on 11-13-2006 11:35 AM

0 Kudos
Message 2 of 6
(6,054 Views)
I suggested that but If I use for example a simple "8" represented as a DBL to say labview that a for-loop has to be iterated eight times, why is it not possible for LV after pressing the run button to adapt that "8"-DBL to an "8"-I8 as it is beacuse during the whole run process the constant does not change or is that a technical problem?
As you said it, for huge programs I want to save memory...

Another question: Does it make a difference to pass a constant into a while / loop or putting it in? In know that control / indicators are read out during each iteration but does LV compensate that for constants?

Thx


0 Kudos
Message 3 of 6
(6,041 Views)
I guess that there is no difference between the usage of a constant inside or outside of a loop because there isn't a thread swap but there will be a difference when you use a control, property node or local variable inside or outside of the loop.

Below are some hints regarding your fixed and floating point arithmetic questions:
-> IEEE 754 Norm:
SGL: 1bit Sign, 8bit Exponent, 23bit Mantissa
DBL: 1bit Sign, 11bit Exponent, 52bit Mantissa
LabVIEW works with normalized values and therefore you have 24/53bit for Mantissa

Smallest presentable value with DBL datatype: 2^-1074
Smallest presentable value with SGL datatype: 2^-149

Number of supported points with DBL: 1.84287E+19
Number of supported points with SGL: 4.26141E+9

Relative rounding error (machine epsilon) for DBL is: 2.22045E-16
Relative rounding error (machine epsilon) for SGL is: 1.19209E-7


BR,  
ThSa
0 Kudos
Message 4 of 6
(6,012 Views)
I have more question realting the programming / processing style of labview to optimize programs. Where can I get information to various questions, so I do not have to ask everything in a thread.

There are turorials for good programming, but this are very small ones and only referes to to loops.

Thx
0 Kudos
Message 5 of 6
(5,976 Views)

Hi,
i think there aren't any short explanations regarding the optimization of loops, memory management and compiler structure.
Below some links that might be helpful:
How LabVIEW Stores Data in LabVIEW
Memory in LabVIEW
Ask Dr. VI 
Ask Dr. VI Archive 

For further information read the LabVIEW help, visit LabVIEW Intermediate I,  LabVIEW Intermediate II or LabVIEW Advanced course or buy the book "LabVIEW for Everyone 3rd Edition".

BR
ThSa

 
0 Kudos
Message 6 of 6
(5,956 Views)