Git Product home page Git Product logo

calc's Introduction

calc

Build Status

A simple, fast, and intuitive command-line calculator written in Go.

Install

Install calc as you would any other Go program:

go get github.com/alfredxing/calc

Usage

You can use calc in two ways: shell mode and command.

Shell mode

This is probably the mode you'll want to use. It's like the python shell or irb. The shell mode uses the terminal package provided by golang.org/x/crypto/ssh/terminal, which means it supports many of the shell features you know and love (like history, pasting, and the exit command).

> 1+1
2
> 3(5/(3-4))
-15
> 3pi^2
29.608813203268074
> ln(-1)
NaN

Command

You can also use calc to evaluate an expression with just a single command (i.e. without opening the shell). To do this, just use calc [expression]:

bash$ calc 1+1
2
bash$

Supported functions, operators, and constants

calc supports all the standard stuff, and I'm definitely adding more later (also feel free to fork and add your own!)

Operators

+, -, *, /, ^

Functions

sin, cos, tan, asin, acos, atan, sqrt, log, lg, ln, abs

Constants

e, pi, ฯ€

Why not use ...?

  • Google
    • Doesn't work without an internet connection
    • Slower
    • Doesn't show previous computations, so you end up with multiple tabs open at once.
  • Spotlight (on OS X)
    • No history
    • Switching between Spotlight and other windows isn't too fun
  • Python/IRB
    • Requires use of a separate math module for most functions and constants
    • A little bit slower to start up
  • bc
    • Limited number of built-in functions; these have shortened (not too intuitive) names as well.

The alternatives above are all great, and have their own advantages over calc. I highly recommend looking into these if you don't like how calc works.

calc's People

Contributors

alfredxing avatar soulou avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.