取消
显示结果 
搜索替代 
您的意思是: 

Inverting a Binary String

Morning Everyone,

 

I need to convert a 19 bit binary string into 1's compliment. (I think that's the right nomenclature?)

 

E.G. I need  1111111110000000010

To become   0000000001111111101

 

I have added a picture of my code.

 

For those curious. I am processing 32 bit ARINC-429 format words from avionics. Specifically, I am using case structures for the temperature and pressure altitude words. The sign bit is the 19th bit, and the data switches the 0s to 1s and 1s to 0s. I need to reverse this so I can convert it into my new negative engineering unit.

 

Thanks everyone!

0 项奖励
1 条消息(共 22 条)
7,250 次查看

Is there a reason you can't just act on the integer value before your Scan Into String?  It would be super simple there to just add in a NOT.



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 项奖励
2 条消息(共 22 条)
7,241 次查看

It all depends what you want to do. If you are only interested in the lower 19 bits, then use the NOT as crossrulz suggested. If you do care about the upper 13 bits and don't want them to change you can always use an XOR with the appropriate mask.

 

use xor.png

 

0 项奖励
3 条消息(共 22 条)
7,231 次查看

See attached VI.

 

George Zou
0 项奖励
4 条消息(共 22 条)
7,228 次查看

What is going into the top of that XOR gate? I have never seen a blue box with a small x in it? Also, what is the significance of the "0007FFFF"

 

Thanks!

0 项奖励
5 条消息(共 22 条)
7,190 次查看

This is very close to what I need. The problem with this is I get a full 32 bits. 19 bits of data plus an additional 13. Since I am converting all the zeros to 1s these padding zeros show up as ones, and my binary to decimal conversion is thrown off.


Any idea how I can truncate these 13 bits off the data to get back to 19 bits? My %19b in my format box doesn't seem to be doing what I thought it would.

 

Thanks

 

-Dave

0 项奖励
6 条消息(共 22 条)
7,189 次查看

@lavid2002 wrote:

What is going into the top of that XOR gate? I have never seen a blue box with a small x in it? Also, what is the significance of the "0007FFFF"

 

Thanks!


Right click on a U32 constant and make the Radix visible.

0 项奖励
7 条消息(共 22 条)
7,172 次查看

you can just convert the integer  to array of boolean and use array palatte to truncate it .

 

but i think using mask as jamiva mention is better.

 

 

Kudos and Marked as Solution == Thanks
0 项奖励
8 条消息(共 22 条)
7,149 次查看

NOT the number to invert it, AND with 7FFFF to 'truncate' to 19 active bits (all above will be 0's).

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
9 条消息(共 22 条)
7,140 次查看

Just plugged this in on my desktop, and it looks like what I need. I'm going to go try it on the airplane now.

0 项奖励
10 条消息(共 22 条)
7,135 次查看