##### Page tree
Go to start of banner

# Script to Convert Base-10 numeric to Base-X

## Description

This article presents a script that will convert a base-10 numeric (decimal) to any base between base-2 (binary) to base-36 (0-9,A-Z).

## Steps:

1. Create three keyboard data source fields on the label (Input, Output, & Base).
2. Create a script data source field on the label (Script).
3. Use the following script:
Sample Script
```// pull input data from label
var input=Number(label.fields.field.(@name=='Input').@data);
var x=Number(label.fields.field.(@name=='Base').@data);

// initialize variables and set base36 array
var base36 = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
var output=new String;
var y=0;

// error handling (not a number)
if(isNaN(input)==true || isNaN(x) ==true)
{
output="Value entered is not a number";
}
else
{
// error handling (not an integer)
if (Math.floor(input) !=input || Math.floor(x)!=x)
{
output="Value entered is not an integer";
}
else
{
// error handling (not a valid integer)
if (input<0 || x<0 || x>36)
{
output="Value entered is not a valid integer";
}
else
{
// determine how many digits will be required
while (Math.pow(x,y)<=input)
{
y++;
}

y-=1;

// calculate digits
for (y=y;y>=1;y--)
{
var digit=Math.floor(input/Math.pow(x,y));
output+=String(base36[digit]);
input-=digit*Math.pow(x,y);
}

output+=String(base36[input]);
}
}
}

// ouptut to label
label.fields.field.(@name=='Output').@data=output;
```

2016014

## Versions

All LLM/LPS versions from 9.5.3 and higher.

## Environment

All supported installation environments.