03-31-2010 03:13 PM
MikeS81 wrote:Hi tbob,
if the number is unsigned and the end is smaller than the start, then the subtraction results in a big number.
Mike
Message Edited by MikeS81 on 03-31-2010 09:30 PM
You are correct in that point. However, there is a coersion dot that appears at the N terminal. Evidently if the difference between start and end is small it gets changed by the coersion dot to a negative number (I32) and the loop doesn't execute. However, if the starting number is much larger than the ending number (start=4294967290, end=5), the difference is actually a positive number after conversion to a signed integer. Then the loop will execute and you will get an unintended result. So a test should be made to ensure that the starting number is less than the ending number to have a completely robust VI.
03-31-2010 03:24 PM
Hi tbob,
you are correct. If it is a U32 (the result from two U32 normally resulting in a negatice number) and i connect it to a for loop (LV 2009) then the loop do not execute. Is it expected behaviour? Where is the difference between a "normal" U32 (value=5) number and the result of the operation 5-12=4294967289? I would expect that the loop iterats 4294967289 times.
Mike
03-31-2010 04:04 PM
I will use a U8 vs I8 to show the difference. With a U8 (unsigned), the range of numbers are from 0 to 255. For I8 (signed), the MSB is the sign bit and is not part of the number, so the range is from -128 to 127. So lets make start and end numbers U8. A start number of 129 with an end number of 1, subtract end minus start and you get -128. But the output is unsinged, so you get 128 instead. But the N in the loop terminal only accepts signed integers, so it sees -128 and does not execute.
Now lets say the start is 130 and the end is 1. The subtraction gives -129, which is beyond the limits of the I8 (-128 to 127), so the number gets converted to 127. The loop executes 127 times.
Apply the same principle for U16-I16 and U32-I32, only the range is much larger.
03-31-2010 04:26 PM
04-02-2010 12:54 AM
04-02-2010 01:10 AM - edited 04-02-2010 01:10 AM
Wierd and not acceptable No:1 - You have posted something totally different and is it not better to start a new thread?.
Wierd and not acceptable No:2 - Why is the above post marked as the solution?
Wierd and not acceptable No:3 - Why are posting the same message under un related threads?????
04-02-2010 02:23 AM