Integer & float calculations examples in linux command line


SUBMITTED BY: Guest

DATE: Jan. 24, 2015, 8 p.m.

FORMAT: Bash

SIZE: 1.0 kB

HITS: 1134

  1. $ echo $((20.0/7))
  2. $ zcalc
  3. $ bc <<< 20+5/2
  4. $ bc <<< 'scale=4;20+5/2'
  5. $ expr 20 + 5
  6. $ calc 2 + 4
  7. $ node -pe 20+5/2 # Uses the power of JavaScript, e.g. : node -pe 20+5/Math.PI
  8. $ echo 20 5 2 / + p | dc
  9. $ echo 4 k 20 5 2 / + p | dc
  10. $ perl -E "say 20+5/2"
  11. $ python -c "print 20+5/2"
  12. $ python -c "print 20+5/2.0"
  13. $ clisp -x "(+ 2 2)"
  14. $ lua -e "print(20+5/2)"
  15. $ php -r 'echo 20+5/2;'
  16. $ ruby -e 'p 20+5/2'
  17. $ ruby -e 'p 20+5/2.0'
  18. $ guile -c '(display (+ 20 (/ 5 2)))'
  19. $ guile -c '(display (+ 20 (/ 5 2.0)))'
  20. $ slsh -e 'printf("%f",20+5/2)'
  21. $ slsh -e 'printf("%f",20+5/2.0)'
  22. $ tclsh <<< 'puts [expr 20+5/2]'
  23. $ tclsh <<< 'puts [expr 20+5/2.0]'
  24. $ sqlite3 <<< 'select 20+5/2;'
  25. $ sqlite3 <<< 'select 20+5/2.0;'
  26. $ echo 'select 1 + 1;' | sqlite3
  27. $ psql -tAc 'select 1+1'
  28. $ R -q -e 'print(sd(rnorm(1000)))'
  29. $ r -e 'cat(pi^2, "\n")'
  30. $ r -e 'print(sum(1:100))'
  31. $ smjs
  32. $ jspl

comments powered by Disqus