GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — shell-script/024-calc.sh at master · srinivart/shell-script

Expand file tree

/

024-calc.sh

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
47 lines (36 loc) · 964 Bytes
/

024-calc.sh

Copy path

File metadata and controls

executable file
·
47 lines (36 loc) · 964 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
# calc - a command-line calculator that acts as a front-end to bc
scale=2
show_help()
{
cat << EOF
In addition to standard math functions, calc also supports
a % b remainder of a/b
a ^ b exponential: a raised to the b power
s(x) sine of x, x in radians
c(x) cosine of x, x in radians
a(x) arctangent of x, returns radians
l(x) natural log of x
e(x) exponential log of raising e to the x
j(n,x) bessel function of integer order n of x
scale N show N fractional digits (default = 2)
EOF
}
if [ $# -gt 0 ] ; then
exec scriptbc "$@"
fi
echo "Calc - a simple calculator. Use 'help' for help, 'quit' to quit."
echo -n "calc> "
while read command args
do
case $command
in
quit|exit) exit 0 ;;
help|\?) show_help ;;
scale) scale=$args ;;
*) scriptbc -p $scale "$command" "$args" ;;
esac
echo -n "calc> "
done
echo ""
exit 0
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.