LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why am I getting bad data when subtracting?

I have a number coming from a vi that I built.  This number is subtracted to give me the data that I want.  Usually the number coming from the vi is larger than the number being subtracted from it.  In some cases, it is not.
 
In this case the minuend, the number being subtracted, is smaller.  This gives me a very large number.  The representation of this number is not unsigned so it has the possibility of being negative.
 
Am I missing something?
 
Thanks for your help in advance.
Ron Deavers, CLD
Message 1 of 6
(4,474 Views)

The number that you are getting is actually correct. When you subtract those 2 numbers you get a negative number (minus 7 thousand and something). If cast to an unsigned number you get the value that you are seeing. You need to ensure that both of your inputs to the subtraction are signed numbers and then the output will be signed as well. I see one coercion dot on the subtraction, so I am assuming that one input is signed and one is unsigned.

     Rob

Message 2 of 6
(4,457 Views)
Programmindragon,
 
Correct if you are using signed data type for the output indicator you should get negative numbers, BUT the data is still the same its just represented different and because you are changing it to a boolean array it shouldnt make a difference.  To fix your problem you will notice that one of the inputs of your subtract icon has a coercion dot on it.  This means that it is a different data representation then the other input which means one of your inputs IS unsigned which is forcing the ouput to be unsigned.  Make sure the data from the VI is signed as well as the constant.
 
Brian

Message Edited by BrianPack on 01-18-2006 05:27 PM

Message 3 of 6
(4,458 Views)

The best thing about this thread is that I learned two new words:

http://www.m-w.com/dictionary/minuend

http://www.m-w.com/dictionary/subtrahend

-D

0 Kudos
Message 4 of 6
(4,431 Views)


Darren wrote:

The best thing about this thread is that I learned two new words:


Darren, I think I'll stick to "subtractor" and "subtractee" , technically incorrect as they are, although I will try to remember these two.


___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(4,415 Views)

Thank you for your help.

I found out that my subVI was returning an unsigned integer.

Ron Deavers, CLD
0 Kudos
Message 6 of 6
(4,388 Views)