I have a variable that is stored as "1.20E20". I would like for it to be changed to "0.0120E22". Is there a simple command to change this value? I tried
let nh=$nh/100
But that did not work; I assume it is because of the character value in the variable. I know there are various solutions; what is the best way to solve this?
I don't know of a way to force
printf
to shift the exponent. Let's do it manually: multiply the coefficient by 10-2, and add 2 to the exponent.We can validate with:
I’d write a simple
bash
script like this:You just need to give it the values as arguments, first the number and then the shift: