Skip to content

Instantly share code, notes, and snippets.

@mhoffman
Created July 5, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhoffman/145a97d2e587c5a0a14a189bc83968eb to your computer and use it in GitHub Desktop.
Save mhoffman/145a97d2e587c5a0a14a189bc83968eb to your computer and use it in GitHub Desktop.
#!/bin/bash
# Turn scientic notation of rational number
in="$(echo ${*} | sed -e 's/\([0-9.]\)[eE]\([0-9+-]\)/\1*10^\2/g' -e 's/--/+/g' )"
# calculate and turn back to scientific notation
printf "%.7f\n" $(echo "scale=63; ${in}" | bc ;exit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment