January 2004
Intermediate to advanced
368 pages
7h 25m
English
Once I wrote Script #9, allowing command-line invocations of bc for floating-point calculations, it was inevitable that I'd write a small wrapper script to create an interactive command-line-based calculator. What's remarkable is that, even with help information, it's very short.
#!/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 ...Read now
Unlock full access