DickD Posted June 21, 2006 Report Posted June 21, 2006 Download File:post-4719-1150910981.vi I am collecting 24 bit words from a serial source as an array and converting them (2 s compliment) to integers I32. Starting out with a 24 boolean element array I move the sign bit (23) to element 31 after resizing the array to 32 bits. From there it is an array to integer conversion. It works ok but I am wondering if I am overlooking a more elegant way of doing this. Thanks Quote
Grampa_of_Oliva_n_Eden Posted June 21, 2006 Report Posted June 21, 2006 Download File:post-4719-1150910981.viI am collecting 24 bit words from a serial source as an array and converting them (2 s compliment) to integers I32. Starting out with a 24 boolean element array I move the sign bit (23) to element 31 after resizing the array to 32 bits. From there it is an array to integer conversion. It works ok but I am wondering if I am overlooking a more elegant way of doing this. Thanks I do not have LV 8 up on a machine at the moment but assuming you already have the 24 bits in the low 24 bits of an I32, I'd would take advantage of bitwise operations and test the sign bit using a mask of "00000000100000000000000000000" and if the result is NOT =0 then do an or with a mask of "1111111100000000000000000000000" See image. I would also to the "Or-ing" inside a case structure so that you are not doing work needlessly. I hope this helps, Ben Quote
David Boyd Posted June 22, 2006 Report Posted June 22, 2006 I am collecting 24 bit words from a serial source as an array and converting them (2 s compliment) to integers I32.Starting out with a 24 boolean element array I move the sign bit (23) to element 31 after resizing the array to 32 bits. From there it is an array to integer conversion. It works ok but I am wondering if I am overlooking a more elegant way of doing this. Thanks Perhaps the attached will be of some use to you. These little data manipulation problems can be solved in so many ways, since LV has a pretty complete set of polymorphic primitives. The VI I've attached is just one way to get there, I'm sure someone else will come along with a cleaner and/or faster approach Best regards, Dave Download File:post-195-1150951577.vi Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.