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.
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.
06-13-2018 11:41 AM
Hello,
Could anyone know why the maximal u8 value would be 128 instead of 255 as it should be? I am trying to convert an array of zeros and ones into the array of zeros nad 255's, so i am converting data array to u8 and trying to use rotate function (http://zone.ni.com/reference/en-XX/help/371361P-01/glang/rotate/) with y=-1...
Any help/ideas appreciated!
Solved! Go to Solution.
06-13-2018 11:53 AM - edited 06-13-2018 11:55 AM
You are not making any sense.
The max U8 value is 255 and if your rotate by -1, you'll end up with 127. Where does your 128 come from? What does an array of zeroes and ones have to do with any of this?
Can you show us some code and real data?
06-13-2018 02:25 PM
@JulIS wrote:
Hello,
Could anyone know why the maximal u8 value would be 128 instead of 255 as it should be? I am trying to convert an array of zeros and ones into the array of zeros nad 255's, so i am converting data array to u8 and trying to use rotate function (http://zone.ni.com/reference/en-XX/help/371361P-01/glang/rotate/) with y=-1...
Any help/ideas appreciated!
128 is is "10000000" in binary. It is the largest value of a U8 where only a single bit is set.
Ben
06-13-2018 02:40 PM
If you're just changing 1's to 255, multiply the array by a constant of 255.
If your data is a binary 1 (00000001) then no matter how you rotate it you'll never get to 255 (11111111). I guess you could subtract 2 from your number instead of rotating?
What are you actually trying to do here?
06-13-2018 03:26 PM
Thank you all for your reply. Yes, I was doing something not very wise suggested by somebody else's code. Thanks a lot!