bc: Power at your fingertips

I haven’t talked about many command-line calculators. I suppose that means jumping straight to bc might be a bit heavy-handed.

2013-08-26-v5-122p-bc

This is not my first run-in with bc; I mentioned it years ago as a solution for calculating at the prompt. I think I said you could balance your checkbook with it. 🙄

I use it from time to time, when I need to find out what 8 gigabytes is in terms of kilobytes, or something odd like that. It’s rare that I put it through its paces.

Which is unfortunate, because bc is a powerful little program. What do I mean by that?

Well, can your pocket calculator estimate pi to the 5000th digit? Can your office calculator? Can Google?

bc can. Start it with bc -l, and try this:

scale=5000; 4*a(1)

After a minute (or two or three or ten 😉 ) you should have an answer. And it will fill your screen.

I haven’t been appreciative enough of this little program (I could say that about a lot of things), and considering how easy it is to use and how flexible it is, that’s a shame.

And I’m tempted to put it all down on “paper,” but someone else already did a better job. If you want a proper introduction on how to use bc, that’s the place to go.

And besides: I have hundreds more applications to look at. 😦 Moving on. …

11 thoughts on “bc: Power at your fingertips

  1. Ander_

    You can do wonders with Python an mpmath (python-mpmath package on Debian repos)

    #!/usr/bin/python
    import mpmath #Load mpmath library
    mpmath.mp.dps = 100 #Decimal precision
    print mpmath.pi #Print pi constant defined on mpmath libray with the previous precision.

    Also, try yo learn Python, at least a little bit. I wrote a program with 5 lines with Python and Json which it prints a list of
    playlist URL’s so you can pipe them to wget and finally, play them with Mocp or Mplayer:

    cat getpls.py
    import urllib2
    import json

    f=urllib2.urlopen(“http://listen.sky.fm/public3/”)
    data = json.load(f)
    a = []
    for i in range(0,len(data)):
    print(data[i][“playlist”])
    ##EOF

    ander@darkstar:~$ python getpls.py | grep jazz | wget -c

  2. Pingback: calc: You knew this was coming | Inconsolation

  3. Pingback: ised: Compact power for calculating | Inconsolation

  4. Pingback: qalc: qalculate!’s text only version | Inconsolation

  5. Pingback: reptyr: Pull the rug out from under your tty | Inconsolation

  6. Pingback: screenify: A tetchy little tool | Inconsolation

  7. Pingback: wcalc: A calculator with a conventional appeal | Inconsolation

  8. Pingback: e: Like a diamond bullet | Inconsolation

  9. Pingback: c, calcc and calccmd: Three small calculators | Inconsolation

  10. Pingback: c, calcc and calccmd: Three small calculators | Linux Admins

Comments are closed.