03-09-2022 08:41 AM
Basically my job is to take a long string that is just a big list of digits with no commas or spaces in between values into an array of Booleans using the fact that an even number represents a Boolean 'True' and an odd represents a 'False'. I know that to start I must have a format string for a scan from string that gives me each individual number from the length of 65,000 so that I can then put it through a case statement that compares it to odd or even and then put that in a Boolean array. The problem is I don't know what format string I should use to get each individual digit. I've attached the string that I want to convert into Boolean below.
03-09-2022 09:03 AM
You have asked the question wrong...
@gch8244 wrote:
The problem is I don't know what
format stringI should use to get each individual digit. I've attached the string that I want to convert into Boolean below.
Have you thought about using String Subset?
03-09-2022 09:07 AM - edited 03-09-2022 09:08 AM
How about a little out-of-the-box thinking here. You could just use the bytes directly. Use String To Byte Array. The values will show up between 0x30 (48) and 0x39 (57). Notice that the even numbers will still have even values. So you can just AND with 1 and a simple comparison and you now have an array of Booleans.
03-09-2022 12:38 PM
How would I then convert that array into an array of 8-bit numbers by using 8 boolean
bits at a time, i.e., the first 8 booleans give a single unsigned 8-bit integer, the next 8 booleans gives the second unsigned 8-bit integer, and so on. The array will thus be reduced in size by a factor of 8.
03-09-2022 01:24 PM
Hi gch,
@gch8244 wrote:
How would I then convert that array into an array of 8-bit numbers by using 8 boolean
bits at a time, i.e., the first 8 booleans give a single unsigned 8-bit integer, the next 8 booleans gives the second unsigned 8-bit integer, and so on. The array will thus be reduced in size by a factor of 8.
You need to use the ReshapeArray function, followed by an autoindexing FOR loop with a BooleanArrayToNumber function inside…
It's really esay!