cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
0 Kudos

Numeric programmer built in conversion functions needed (Decimal <-> Binary <-> Hexadecimal)

I have several scripts that I use to convert columns with decimal values over to binary column, or vice versa.   It would be so much easier to not have to run a script if a column could have a built in function(s) to convert to/from Decimal, Binary, and Hexadecimal.  That way just sharing a table with others would not require "instructions" to run scripts if the table got updated.

 

It would also be great if it could be parameterized so the output is X digits after converting (especially when converting decimal to binary)

E.g., 

DECTOBIN ( 3,   -->  00000011

DECTOBIN ( 3, 4) -->  0011

 

BINTODEC (0011) --> 3

 

5 Comments
justvince
Level III

DECTOBIN ( 3,  -->  00000011

justvince
Level III

Looks like ",8)" will not post....  DECTOBIN ( 3, "eight") -->  00000011

Jeff_Perkinson
Community Manager
Status changed to: New

You can create an add-in out of your conversion functions and add them to the Formula Editor. In this way you can share your library of functions with others easily. They won't have to run scripts the add-in will load when they start JMP and the formulas will update approrpiately with data changes.

 

Take a look at Conversion Function Library for a design pattern for this type of add-in. After downloading and installing it, go to the View->Add Ins menu and look at the contents of the add-in to see how you might use that patter or extend that add-in.

RayE
Level II

Hi, 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

RayE_0-1650655039783.png

 

 

hogi
Level XII

As an alternative to @Jeff_Perkinson 's suggestion, you could use the built-in functions Hex and Hex to Number:

Hex( 3, Base( 2 ), Pad To( 8 ) );
Hex( 3, Base( 2 ), Pad To( 4 ) );

Hex To Number( "0011", Base( 2 ) );

Regarding single bit access, there is no function available at the moment.
Please follow this link and support the wish with a Kudo:
JSL bit operations