Git Product home page Git Product logo

ncalc's Introduction

Command line utility for quick number base conversions ( ascii / binary / octal / decimal / hexadecimal ).

release-badge circleci-badge

NAME:
    ncalc โ€“ number base converter.

SYNOPSIS:
    ncalc [ opts... ] [ number|character ]

OPTIONS:
    -h, --help                  print usage.
    -i, --input format          input format. see FORMATS. (default: decimal|ascii)
    -o, --output format         output format. see FORMATS. (default: all)
    -q, --quiet                 suppress printing of output format type(s)
    -v, --version               print version number.

FORMATS:
    (a)scii                     character
    (b)inary                    base 2
    (o)ctal                     base 8
    (d)ecimal                   base 10
    (h)exadecimal               base 16

EXAMPLES:
    ncalc "6"                               # output `decimal` number `6` in `all` formats
    ncalc "G"                               # output `ascii` character `G` in `all` formats
    ncalc -i a "f"                          # output `ascii` character `f` in `all` formats
    ncalc -i decimal -o ascii "15"          # output `decimal` number `15` as `ascii`
    ncalc --input h --output o "ff"         # output `hexadecimal` number `ff` as `octal`

Installation

Golang

$ go get -u github.com/clarketm/ncalc

Install script

$ git clone "https://github.com/clarketm/ncalc.git"
$ cd ncalc && sudo sh install.sh

Source (Mac/Linux)

# List of builds: https://github.com/clarketm/ncalc/releases/

$ BUILD=darwin_amd64.tar.gz     # Mac (64 bit)
# BUILD=linux_amd64.tar.gz      # Linux (64 bit)

$ BIN_DIR=/usr/local/bin        # `bin` install directory
$ mkdir -p $BIN_DIR

$ curl -L https://github.com/clarketm/ncalc/releases/download/v1.1.2/$BUILD | tar xz -C $BIN_DIR        # install

Source (Windows)

Usage

Convert ascii to decimal

# Short form
$ ncalc -i a -o d 'w'

decimal: 119


# Long form
$ ncalc -i ascii -o decimal 'w'

decimal: 119


# Very long form
$ ncalc --input ascii --output decimal 'w'

decimal: 119


# Quite mode (-q|--quiet)
$ ncalc -q -i ascii --output decimal 'w'

119

Convert decimal to binary

$ ncalc -i decimal -o binary 170

binary: 10101010

Convert binary to decimal

$ ncalc -i b -o d 10101010

decimal: 170

Convert ascii to all formats

$ ncalc -i a 'G'

ascii: 'G'
binary: 1000111
octal: 107
decimal: 71
hexadecimal: 47

You can see the full reference documentation for the ncalc package at godoc.org, or through go's standard documentation system:

$ godoc -http=:6060

# Open browser to: "http://localhost:6060/pkg/github.com/clarketm/ncalc"  to view godoc.

ncalc's People

Contributors

clarketm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ncalc's Issues

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.