monkeyUser
monkeyUser

Reputation: 4671

Convert Hex to Dec in bash

I want to convert Hex to decimal. I'm using Zsh, but even bash command is ok

For now I try with

echo $((0x0000000000000000003218a50000000000000000000000000000000000000000))

but the result is truncated

zsh: number truncated after 34 digits: 0000000000000000003218a50000000000000000000000000000000000000000
3609816520756035584

I want the same result that I retrieve from this website

input

0x0000000000000000003218a50000000000000000000000000000000000000000

output

4798269179035823348880781507454323228379569035237392384

I'm using mac

Upvotes: 2

Views: 556

Answers (1)

deathangel908
deathangel908

Reputation: 9699

You can use bc. Note letters should be in upper case. You can use this answer to convert.

 echo "obase=10; ibase=16; 0000000000000000003218A50000000000000000000000000000000000000000" |bc

Upvotes: 3

Related Questions