cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
data_nerd
Level II

Hex to Binary

I have a HEX number that I want to convert to binary. I can do this manually for one hex at a time from this website (Hex to Binary Converter), but I can't figure out how to do this in jmp. 

 

Example from the web: 

data_nerd_2-1730831001989.png

My attempt in JMP: 

data_nerd_0-1730832014434.png

HEX2BIN formula:

data_nerd_0-1730830786748.png

Any guidance would be much appreciated. Thanks!

 

Links that haven't helped so far: 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Hex to Binary

Here is my brut force way of handling this

Names Default To Here( 1 );

theArray = ["0" => "0000",
"1" => "0001",
"2" => "0010",
"3" => "0011",
"4" => "0100",
"5" => "0101",
"6" => "0110",
"7" => "0111",
"8" => "1000",
"9" => "1001",
"A" => "1010",
"B" => "1011",
"C" => "1100",
"D" => "1101",
"E" => "1110",
"F" => "1111"];

theHex = "F061F997862C3E70";
theBinary="";
for(i=1,i<=length(theHex),i++,
	theBinary = theBinary || (theArray << getvalue(substr(theHex,i,1)))
);

Show(theBinary);
Jim

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Hex to Binary

This might give some ideas hextonumber not working with 64bits 

jthi_0-1730831693558.png

 

 

-Jarmo
mzwald
Staff

Re: Hex to Binary

data_nerd
Level II

Re: Hex to Binary

The thread mentioned says

  1. To break my HEX string in half and then proceed with the conversion to binary. I've tried that in rows 2 and 3 below without success. I don't mind break it up into individual characters, but still can't figure out how to get 0s and 1s.
  2. To specify the base(16) inside of the Hex To BLOB, but no additional inputs seem to be allowed in Hex To BLOB
  3. To switch to python in JMP 18, but I unfortunately only have access to JMP 17.2.0

Any other ideas? I'm trying to get a series of 1s and 0s. 

data_nerd_0-1730833101613.png

 

 

txnelson
Super User

Re: Hex to Binary

Here is my brut force way of handling this

Names Default To Here( 1 );

theArray = ["0" => "0000",
"1" => "0001",
"2" => "0010",
"3" => "0011",
"4" => "0100",
"5" => "0101",
"6" => "0110",
"7" => "0111",
"8" => "1000",
"9" => "1001",
"A" => "1010",
"B" => "1011",
"C" => "1100",
"D" => "1101",
"E" => "1110",
"F" => "1111"];

theHex = "F061F997862C3E70";
theBinary="";
for(i=1,i<=length(theHex),i++,
	theBinary = theBinary || (theArray << getvalue(substr(theHex,i,1)))
);

Show(theBinary);
Jim