Skip to content

Instantly share code, notes, and snippets.

@mhoffman
Created November 7, 2017 17:42
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/5839d122c9e0f3f82522ec9263d65f28 to your computer and use it in GitHub Desktop.
Save mhoffman/5839d122c9e0f3f82522ec9263d65f28 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