Home > Blockchain >  Calc a value on its decimal version
Calc a value on its decimal version

Time:11-29

1 gwei = 0.000000001 ether

There's a program that displays only 156489673002 (156 gwei), which is 0.000000156489673002 ether.

But how to, in Bash, calculate how many ether is 156489673002 (so the output is 0.000000156489673002)?

CodePudding user response:

You can get the result with awk:

echo "0.1 0.1" | awk '{printf "%.18f\n", 156489673002 / 1000000000000000000}'

or

echo "0.1 0.1" | awk '{printf "%.18f\n", 156489673002 / 1e18}'
  • Related