Code Monkey home page Code Monkey logo

numconv's Introduction

Number Convert

This is a small tool to convert number to different formats.

show

Generate

We will build it with flag -std=gnu99, cause we use some uitility that c99 does not support. Here is the command:

$ make

Usage

  Usage: ./nc [options]

  Options:

    -V, --version                 output program version
    -h, --help                    output help information
    -a, --all <num>               convert number to all formats
    -b, --bin [num]               convert number to binary format
    -d, --dec [num]               convert number to unsigned decimal format
    -H, --hex [num]               convert number to hex format
    -o, --oct [num]               convert number to octal format
    -s, --signed [num]            treat number as signed and set output bits

Now, it supports to convert several numbers one time. By changing the macro MAX_NUMBERS to modify the amounts of number which you want to convert at one time.

Example

We define the number input format:

  • binary 0bxxxxx
  • octal 0xxxxx
  • hex 0x/0X
  • dec +123/-123 [do not started with 0]

Here some examples:

  1. convert two different numbers into binary format
$ ./nc -b 123 -b 0x123 
  1. convert a decimal to other three different format
$ ./nc -a 123
  1. convert number1 to decimal and number2 to binary and octal
$ ./nc -d number1 -b -o number2
  1. convert negative number to other format
$ ./nc -a -- -5

more....

Note: When convert negative number, we need to add -- before number.

numconv's People

Contributors

jesseeisen avatar

Stargazers

Roman avatar  avatar

Watchers

James Cloos 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.