> For the complete documentation index, see [llms.txt](https://docs.midpointapi.com/midpoint-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.midpointapi.com/midpoint-documentation/tasks/shift-decimal.md).

# Shift Decimal

The Shift Decimal task is a purely functional task that takes two values - A and B - and outputs A \* 10^B.

This task can be used to transform floating/fixed point values into integer values 2.54812 —> 254812. This task is commonly used to normalize price data into EVM-compatible formats. This task can also be used to convert a large EVM-normalized value (ex. 1500000000000000000 wei) into a human-readable format (1.5 Eth).

## Definition

```graphql
inputValue: string # Required
decimalPlaces: string # Required
outputName: string # Required
round: string 
extracts: [ 
    {
        name: string 
        from: string
    }
]
excludeLogs: [string]
```

**`inputValue`: Numeric.** The value to be transformed.

**`decimalPlaces`: Numeric.** The number of decimal places to move the value. Positive values means the decimal is moved to the right.

**`round`: Boolean.** Whether or not to round the output down to the nearest integer value.

**`outputName`: String.** The name to be assigned to the resultant value. This is the name that will be extracted.

**`extracts`: See** [**extracts**](/midpoint-documentation/core-concepts/midpoints/source-and-task-definitions/extracts.md)**.** Legal values:

* **`Timestamp`** Unixtime of execution.

**`excludeLogs`: See** [**exclude logs**](/midpoint-documentation/core-concepts/midpoints/source-and-task-definitions/exclude-logs.md)**.** Legal values:

* **`TaskDefinition`** The complete definition of this task at runtime.
* **`TaskOutputData`** The complete set of returned values from this task.

## Returned Values

This task returns one numeric value which is assigned the name given by `outputName` along with any extracts.

## Examples

Takes a value in Ether produced by a previous source/task. This scales the value up by 10^18 to produce a value in Wei which can be used back on-chain.

{% code title="" %}

```json
{
	"inputValue": "{{valueInEth}}",
	"decimalPlaces": "18",
	"outputName": "valueInWei",
	"round": "true"
}
```

{% endcode %}

Takes the value and decimal count of an erc20 balance from a previous source/task. Scales the value down by the decimal count. Ex: 65 USDC is expressed as 65000000 USDC and USDC has a decimal count of 6. This normalizes the value to 65 for use in future tasks.

```json
{
	"inputValue": "{{erc20-value}}",
	"decimalPlaces": "-{{erc20-decimals}}",
	"outputName": "erc20-shifted",
	"round": "true"
}
```

## Tips for Using Shift Decimal

* Use a variable extracted from a previous task (ex. a value from a price API or an on-chain value) as an `inputValue`.
* Only use a variable for `decimalPlaces` if it is not possible to know the translation factor before runtime.
* Set `round` to true if you are returning a value back on-chain and to false if you are creating a human-readable value.
* Ignore `extracts` unless there is a critical need for the timestamp.
* Typically you should ignore `excludeLogs`. It is rare that your exponentiation needs to be concealed from logs.
