# Convert Hex integer to number (chainlink)

I have a smart contract that returns the price of ETH using Chainlink. When i call getPrice() from geth i get a very large HEX number. How can i get the decimal number out of the hex value?

``````constructor (address _manager) ReentrancyGuard() {
manager = _manager;

priceFeed = AggregatorV3Interface(ETH_USD_RINKENBY);
}

function getPrice() public view returns (int)
{
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
) = priceFeed.latestRoundData();

//uint8 decimals = priceFeed.decimals();

return price;
}
``````

returned values example

"

Using javascript you can use `parseInt`! Not only does it take regular string numbers, it also takes hex strings!

The interface is `parseInt(string, radix)` The second argument is the "radix" - which is a math term for essentially "base"

For your example above (taking the first hex string) `parseInt('0xfd918bdff54b7c2d1b639fe258ea80d8f00c68e096cce9cef69b42ff6b19522d', 16)`

gives me `1.1469230889660214e+77`

• Usually it is not a good idea to use javascript numbers because they don't have enough precision to hold a uint256. Either use a library like BN.js, BigNumber.js, etc. or `BigInt` if your js stack support them.
– Ismael
Commented Jun 14, 2022 at 15:25
• Great point! I will add this to the answer in a min. Commented Jun 15, 2022 at 16:42

Do not use `parseInt()`! It has floating point errors with large numbers. You should do the following:

`BigInt(hexString).toString()`

The issue with `parseInt(hexString)` is that it outputs a number, which has a max value of `9007199254740991`. This seems large, but if you are working with `wei` in Ethereum, you know that this number is only ~0.009 Ether. Yikes!