From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-06-2016 08:17 AM - edited 09-06-2016 08:30 AM
Hi,
I just met a problem with 9-digits in binary bit operation.
Long time ago, I manipulated some binary and remembered that the first digit could be considered as significant or other specical meaning.
Though I guess the solution as the attachment, I would like to know the right technique in binary operation.
1) How can I replace the FOR loop with a simple bit operator?
2) I am trying to use U16 (16 bit) to adopt all nine digits but how to remove the first digit or some digits in sequence as a final data? (In my code, I just substract a number from the calculated number.)
for example, (1)101000111 ->101000111 or (11)01000111 ->01000111
3) In other curious question, the lower three digits (111) is fixed in my application.
How can I separate or add the digit in calculation for simplicity?
for example, 110100(high)+(or some operation)111(lower)=110100111
labmaster.
code: LabVIEW 2014.
Solved! Go to Solution.
09-06-2016 08:24 AM
09-06-2016 08:27 AM
Thanks!. I forgot digital operation at all.
I revised my posting. Can you review my question again?
09-06-2016 08:41 AM - edited 09-06-2016 08:42 AM
@labmaster wrote:2) I am trying to use U16 (16 bit) to adopt all nine digits but how to remove the first digit or some digits in sequence as a final data? (In my code, I just substract a number from the calculated number.)
for example, (1)101000111 ->101000111 or (11)01000111 ->01000111
I typically use an AND to mask off the bits I do not care about.
@labmaster wrote:3) In other curious question, the lower three digits (111) is fixed in my application.
How can I separate or add the digit in calculation for simplicity?
for example, 110100(high)+(or some operation)111(lower)=110100111
That is typically done with some interesting masking (with the AND) or setting of bits (with the OR) and the Logical Shift.
09-06-2016 08:43 AM - edited 09-06-2016 08:44 AM
09-06-2016 09:12 AM - edited 09-06-2016 09:15 AM
Thanks for your additional comments.
if x=3 (decimal), y=00010 (binary)
if x=64, y=11111
There is an offset (-1 in decimal) for simple equation.
The problem to me is how to treat the most significant digit.
How can you set up a formula using the bit shift or boolean operation without any numerical operator?
labmaster.
09-06-2016 09:23 AM - edited 09-06-2016 09:29 AM
Hi master,
The problem to me is how to treat the most significant digit.
What exactly is the problem?
Do you have specifications/requirement on how to handle the MSB? Then apply them!
(If needed you apply your rules to each mathematical operation!)
How can you set up a formula using the bit shift or boolean operation without any numerical operator?
Why do you want to have mathematical operations without using mathematical operators?
It seems to me you are talking about "saturated arithmetic" (see Wikipedia). Can you describe the algorithm you want to program?