LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect Multiply Result?

Solved!
Go to solution

I'm doing the following, and received the wrong value. Is there something I'm missing?

 

Untitled.png

0 Kudos
Message 1 of 7
(2,653 Views)

Why is this incorrect?

 

anything x 0 = 0 and -0 = 0

0 Kudos
Message 2 of 7
(2,638 Views)

To prove that -0 is equal to 0, add an increment by 1 after the multiply and before your indicator.  The math is correct, it may just look wonky.

0 Kudos
Message 3 of 7
(2,627 Views)

I mean it makes sense. The reason why I ask is because problem arises when I try to convert this is an string which now becomes "-0". Doing any comparisons fails immediately. Is there a reason why LV does this, rather than follow -1 * 0 = 0?

0 Kudos
Message 4 of 7
(2,612 Views)
Solution
Accepted by Tom321

Well, there is a sign bit in the IEEE754 specification.  When multiplying, the two sign bits should just be XORed.  -1 has a sign of 1 (negative) while 0 has a sign of 0 (positive).  XOR the values and you get 1 (negative).  This results in -0.

 

For additional reading: Signed zero


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(2,605 Views)

@Tom321 wrote:

Doing any comparisons fails immediately.


Define "fail". If you do the comparison on the numerics, you can see that -0 and 0 are equal as expected.

 

NoSign.png

Message 6 of 7
(2,517 Views)

@altenbach wrote:

@Tom321 wrote:

Doing any comparisons fails immediately.


Define "fail". If you do the comparison on the numerics, you can see that -0 and 0 are equal as expected.


Tom321 did sort of define it.  He stated that he converts to a string and then does comparisons.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 7
(2,459 Views)