LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Breaking a number into it's component byte

Solved!
Go to solution
Highlighted

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
(720 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
(707 Views)
Solution
Accepted by topic author pedroseger

!1-1.png

Just a bit if bit manipulationSmiley Wink

Always maintain an accurate count of deployed mousetraps.
Message 3 of 3
(702 Views)