Need a script to read a single bit in am 8 bit codeHi, I have been trying to find a way to read one bit in an 8-bit code (column RegRead) to be used to create a new column.
I can't seem to know to do it. in this example below, I am trying to ready bit[3], can someone help with it
much appreciated.
Ray

Data TableRe: Need a script to read a single bit in am 8 bit codeIs that what the data looks like in a JMP data table? Is the column a character column or a numeric column? There are at least 3 different possibilities:
If the data is already characters, "1" and "0", then the substr() function should be able to grab the 5th character (assuming the leading "0" characters are present.) Test carefully; if you call the LSB bit 0 vs bit 1 changes the answer, and substr starts at 1, not 0.
If the value is a number, weirdly showing a base 10 number that looks like a base 2 number, (1) you might want to re-import it as character or (2) you might use mod(floor(RegRead/1000),2).
If the value is a number between 0 and 255, you might use mod(floor(RegRead/8),2). Divide by 8 shifts the bit pattern three places to the right, floor throws away the fraction, mod-2 is 1 for odd answers when the LSB is 1.
Another possibility might be numeric from -128 to 127 if the transfer somehow thinks the MSB is a sign bit.
Re: Need a script to read a single bit in am 8 bit codehere is actual example of columns (smaller dataset) with each column's info, the decimal column is Numeric and Binary column is a Character.
I am interested in the Binary column only; the LSB will change from 0 to 1 based on test data collected and programming of each register.
I do use this formula to convert from Dec to Binary
dt << New Column ("RegRead_Binary", formula(decimalToBinary = Hex(:RegRead, Base(2), Pad To(3))));
Thanks again

Re: Need a script to read a single bit in am 8 bit codeThanks Craige
you gave the idea to use SUBSTR() function and I tested it out with random columns Test1,2,3
dt << New Column ("Extract_Bit5", formula(SUBSTR(:Test1, 5, 1)));
dt << New Column ("Extract_Bit7", formula(SUBSTR(:Test2, 1, 1)));
dt << New Column ("Extract_Bit0", formula(SUBSTR(:Test3, 8, 1)));
results
