LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove tailing zero in U32

Hello,
 
I am trying to change the format of a U32 number so that all bytes are reversed without tailing zeros, and I am not that familiar with formatting numbers and strings.  Please kindly advise how my VI should be changed to accomplish that.  Thanks a lot for your help.
 
Valen
-------------------------------------
 
What I want to achieve:
x12345678 --> x78563412
x123456     --> x563412
x2               -->x 2
 
My Results:
x12345678 --> x78563412
x123456     --> x56341200
x2               -->x 2000000 
 
My VI:
U32-->Swap words-->Swap bytes-->U32
 
----------------------------------------------
 
 
 
0 Kudos
Message 1 of 5
(2,963 Views)
Valen,

1. Convert number to string to byte array.
2. Reshape array to 5X2. (This will handle the largest possible U32 value.)
3. Separate rows.
4. Convert each row to string.
5. Concatenate strings in reverse order.
6. Remove null bytes "\00".
7. Convert back to U32.

I think an easier way exists, but this is what came to mind.

Lynn
Message 2 of 5
(2,951 Views)
Try this (LabVIEW 7.0) 😄
 

If course if you only need to convert a single U32 scalar, use the code inside the loop.

Message Edited by altenbach on 07-13-2006 12:23 PM

Download All
0 Kudos
Message 3 of 5
(2,945 Views)
Here's a version that is a bit more compact, eliminating the (-1).
 

Message Edited by altenbach on 07-13-2006 12:56 PM

Message 4 of 5
(2,933 Views)
Hello Lynn and Altenbach,
 
Both solutions works perfect.  I really appreciate your great help, it saves me easily a couple hours of coding time. 
 
Thanks again,
Valen
0 Kudos
Message 5 of 5
(2,917 Views)