LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you join more than 2 numbers? Such as, three U16's where there's a High, Mid, and Low?

Solved!
Go to solution

Subject says it all really. I'd like Join Numbers to be scalable, but it isn't. So, What's the easiest way to do this?

0 Kudos
Message 1 of 6
(111 Views)
Solution
Accepted by rds2112

snip.png

Message 2 of 6
(98 Views)

I was so close. Your method doesn't have the coercion dot! Thanks!

0 Kudos
Message 3 of 6
(90 Views)

@rds2112 wrote:

I was so close. Your method doesn't have the coercion dot! Thanks!


I assume you just connected your High to the top hi input. It is just coercing the value to a U32. The upper bits of that should all be zeros if you are using a U16, so it should not matter in this case. If you are in a tight loop, the coerce maybe faster.

0 Kudos
Message 4 of 6
(84 Views)

I was getting a lot of zeros where I didn't want them. Your method makes more sense for parsing while displayed in binary.

0 Kudos
Message 5 of 6
(81 Views)

@rds2112 wrote:

Subject says it all really. I'd like Join Numbers to be scalable, but it isn't. So, What's the easiest way to do this?


How should it be made scalable? there is no 24bit or 84bit integer type, for example.

 

You already got a good solution but for more complicated problems, e.g. parsing a 1D U8 array of [R,G,B,R,G,B,R,G,B] to a U32 array of [RGB, RGB, RGB] etc. is often needed.

 

An alternative is the good old typecast, of course. Becomes more practical if you want to join 8 U8 values into a U64, for example. Using a fallen Christmas tree of "join numbers" will get tedious!

 

(Just make sure to pad correctly if the input is short.)

 

altenbach_0-1739325086776.png

Also be aware of the desired byte order of the result.

0 Kudos
Message 6 of 6
(13 Views)