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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Breaking a number into it's component byte

Solved!
Go to solution

Hey, guys.

I know about the existance of the Split Number function. But my problem is a little different. 

Let's say I have a 12 bits byte. It is something like this: 0000-1111-1111-1111 or 0FFF.

When i use the Split Number, I get 0F and FF. 

But I'm intending to have something like this: 0011-1111 + 0011-1111.

I mean, I want to break my 12bits number into a 6+6bits, not into a 4+8.

What tools should I use to have this result?

Thanks!

0 Kudos
Message 1 of 3
(2,546 Views)
Solution
Accepted by topic author pedroseger

1.  AND with 2^12-1 (12 1's) so that you know you are keeping lowest 12 bits (if you want)

2.  AND with 2^6-1 to return the lowest 6 bits

3.  Right-Shift 6 bits to return the upper 6 bits

 

Or use Integer quotient and remainder.

 

Divide by 2^6, quotient is upper, remainder is lower

Message 2 of 3
(2,533 Views)
Solution
Accepted by topic author pedroseger

!1-1.png

Just a bit if bit manipulationSmiley Wink


"Should be" isn't "Is" -Jay
Message 3 of 3
(2,528 Views)