Showing results for 
Search instead for 
Did you mean: 

why is loop iterator signed and not unsigned?


Why is the data type of loop iterator a signed integer rather than an unsigned integer?  

Message 1 of 10

now this is a question I would like to know the answer.


When discussing with work colleagues we came to the possible conclusion that it was related to something in the very earlier versions of LabVIEW and has stuck ever since.


Be cool to get some input on this one Smiley Happy

Lewis Gear CLA

0 Kudos
Message 2 of 10

I'd hazard a guess it'd be something to do with pre-initial conditions. So if t0 relied of t(-1), t(-2) etc, you could do it get the appropriate t-value with decrements rather than having to do nested first runs or something.

0 Kudos
Message 3 of 10

I32 is much more universal, and is for example used for array indices, array sizes, etc. The iteration terminal is most often connected to one of those functions. Your diagram would have the measles, with coercion dots all over without I32 on the iterator.


If you need to keep count with e.g. U32 or U64, you can make your own using a shift register and +1 function. Smiley Very Happy


(There are ideas to make the representation changeable according to your needs. See also my comment here)

LabVIEW Champion Do more with less code and in less time
Message 4 of 10

@altenbach wrote:

Your diagram would have the measles, with coercion dots all over without I32 on the iterator.



Not if you make your coersion dots blue.

0 Kudos
Message 5 of 10

I'll hazard a guess here.


Array indexing uses signed integers because a common calculation involves relative indexing (How far is this element from that element?  or, What is the value of the element N past, or N before, this element?), which implies subtraction operations on two index values, which would be a real pain if we had to re-cast that delta index value.


And if we accept that array indicies should be signed, then logically the iteration terminal on loops must be too.



David Boyd
Sr. Test Engineer
Philips Ultrasound
Certified LabVIEW Developer
0 Kudos
Message 6 of 10

It is also useful to have the special value -1, for instance when searching the array.

Basically here the sign bit is carring the result of the operation.




Message 7 of 10

Altenbach and Marco hit the nail on its head.

Indeed, I32 was chosen be compatible to esp. array functions where a certain negative value has a significant meaning: -1


If you use Search 1D Array to find an element within an array, but that element is not present, the return value of the function is -1. So -1 indicates a "not found".

Integer values do not "know NaN (not a number)", so there is not much choice than to use negative numbers (since '0' is the first array element!).


hope this clears things up,


CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 10

@Norbert_B wrote:

Altenbach and Marco hit the nail on its head.






While having dinner with one of the other contributors here I wa asked the same question and my reply to them was as mentioned above.


It is nice to get independent confirmation without asking for it.


Thank you!




0 Kudos
Message 9 of 10

Isn't the unspoken question here: "why are integers blue"?

0 Kudos
Message 10 of 10