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.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I divide a number into bytes

I tried the icon called "split number". It didn't work for me.
0 Kudos
Message 1 of 2
(2,887 Views)
Pushpa,

"split number" is certainly the VI that I would recommend you use. Keep in mind that it splits the input into two equal parts. If you input a 32-bit integer, the high 16 bits and low 16 bits correspond to the two outputs. You'll then need to split one of the previous outputs into its high and low components to access each individual byte.

You could also construct a mask, bitwise AND it with your number, and then shift the result the appropriate number of bits. However, for the sake of simplicity, I recommend that you use "Split Number."

Alan
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,887 Views)