ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2's complement

Hi GerdW,

     This is a useful bit of code.  May I please have your permission to use it?  Thank you!

 

Best Regards,

NFarrell

0 Kudos
Message 21 of 25
(2,368 Views)

Hi NFarrell,

 


@NFarrell wrote:

This is a useful bit of code.  May I please have your permission to use it?


Well, after having posted that piece of code 15 years ago for public use I still can grant you permission to use it! 😄

 

(15 years later I would not use such code anymore, but would use the integer approach as shown by Christian Altenbach. You should do so too.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 22 of 25
(2,363 Views)

Hi,

 

after getting a Kudo for a ~20 year old message I would like to add this: Don't use that old VI anymore!

 

You can do the same with a single BooleanArrayToNumber node when configuring its output to I16 (or I32) and setting the SignExtensionMode (in the node context menu) to "If output is signed"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 23 of 25
(642 Views)

@GerdW wrote:

 

after getting a Kudo for a ~20 year old message I would like to add this: Don't use that old VI anymore!


Hey, it's not my fault that a google search for 'LabVIEW 2s complement' gave me your forum post as the first hit. I was in a hurry! 😛

0 Kudos
Message 24 of 25
(596 Views)

Some more background on sign extension with links to discussions.

0 Kudos
Message 25 of 25
(582 Views)