Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert scientific notation bash script

Tags:

bash

decimal

I have a awk script that grabs numbers that I want. But the problem is they are in this kind of format: 1.8200E+02

In bash script this decimal notation is not supported so I was wonering anyone can help me with this problem.

like image 777
do yong kim Avatar asked Feb 29 '12 21:02

do yong kim


2 Answers

My last answer was wrong, sorry about that. You can use printf for this:

printf '%.0f' 1.8200E+02
182
like image 138
Eduardo Ivanec Avatar answered Oct 15 '22 13:10

Eduardo Ivanec


I don't know of a better solution...

number=1.8200E+02
python -c "print float('$number')"
like image 7
Gandaro Avatar answered Oct 15 '22 13:10

Gandaro