Giter Club home page Giter Club logo

nconv's Introduction

nconv

nconv example

CI status GitPack POSIX Shell Hits

Nconv (number converter) is a simple and intuitive tool for converting among binary, decimal, and hexadecimal numbers. It was created with programmers in mind. Have a look at its sleek features and convince yourself:

  • Smart conversions based on the first number
  • Perfect support for two's complement
  • Numbers may have arbitrary length

To ensure that nconv will work out of the box on as many systems as possible, it was designed as a very portable POSIX Shell script, which also means no need for compilation. Just install and use immediately.

Install

Nconv supports GitPack. Local installation/update:

gitpack install github.com/dominiksalvet/nconv

Usage

Smart conversion:

nconv <number>

Rules: bin → dec, dec → bin, hex → dec.

Manual base conversion:

nconv -b/-d/-h -B/-D/-H <number>

Input options are lowercase, output ones are uppercase.

Manual signedness conversion:

nconv -s/-u <number>

Input is considered to be signed/unsigned.

Manual width conversion:

nconv -W <width> <number>

Extend output to <width> digits. It respects signedness.

An interactive mode will be launched when no number provided.

Examples

To better imagine how nconv works, there are some examples below.

  • Convert a hexadecimal number to a binary number:
$ nconv -B face
1111101011001110
  • Make sure input is always hexadecimal even when smart conversion tells otherwise:
$ nconv -h -B 10
10000
  • Negative numbers are not a problem either:
$ nconv -5
1011
  • Let us extend it to a byte:
$ nconv -W 8 -5
11111011
  • What about to try something bigger?
$ nconv -W 8 -255
E13: could not fit 100000001 into 8 digits
  • Oops, but it would fit without the minus sign, wouldn't it?
$ nconv -W 8 255
11111111
  • Can I store this number into a signed byte variable? Nope.
$ nconv -W 8 -s 200
E13: could not fit 011001000 into 8 digits
  • What is this signed binary number in decimal?
$ nconv -s 10011001
-103
  • I want to be sure I convert right – show me extra details.
$ nconv -x 1000
8
unsigned bin -> dec
input-digits 4
output-digits 1

Useful Resources

nconv's People

Contributors

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