GithubHelp home page GithubHelp logo

00mjk / pcalc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vapier/pcalc

0.0 0.0 0.0 173 KB

command line util for doing hex/dec/oct/bin math quickly

Home Page: https://vapier.github.io/pcalc/

License: GNU General Public License v2.0

Makefile 5.63% C 56.93% Yacc 19.06% Lex 18.38%

pcalc's Introduction

pcalc: The Programmer's calculator

Build Status

There was always a loophole when it came to a need to covert between hexadecimal / decimal / octal / binary.

Especially if it involved an operation like 0x1234 + 0x20. It took a lot of hard work, and mostly a good pocket calculator.

Features

  • Full math parser, parentheses, add, sub, mult, div, exponential
  • Automatic conversion between HEX DEC OCT BIN numbers
  • Mixing different bases in one expression
  • Definable variables
  • Math constants (E PI ...)
  • Built in math functions (sin/cos/sqrt ...)

Examples

Here are bunch of common examples.

See the SYNTAX.md file for the full syntax. You can also run pcalc for a local reference.

$ pcalc 0x300
        768                     0x300                   0y1100000000

# Note: Shell expansion on the '*' char requires the single quotes.
$ pcalc '0x300 + 3 * 3'
        777                     0x309                   0y1100001001

$ pcalc sqrt 2
        1.414213562373095       0x1                     0y1

# Note: The single quotes are to keep the shell happy with the () characters.
$ pcalc 'sqrt(2)'
        1.414213562373095       0x1                     0y1

$ pcalc 0x12 or 23
        23                      0x17                    0y10111

# To execute a script, use the `@` prefix on the filename.
$ pcalc @pcalc.001

Building & Installing

To compile the project, simply use make:

$ make

Note: Some platforms might not provide flex or -lfl. You will need to adjust the Makefile accordingly.

To install it, you can do:

$ sudo make install

Testing

To run the unittests, use:

$ make check

Note: Depending on the precision of floating point math in your system, some unittests might fail. It's OK to ignore those specific failures.

Feedback

Please use the GH issue tracker for any updates/ports/suggestions. Feedback always welcome!

https://github.com/vapier/pcalc/issues

License

This project is licensed under GPLv2 (or later). The full text can be found in the COPYING file.

pcalc's People

Contributors

vapier 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.