js-in-bits
js-in-bits makes converting between decimal, binary, hexadecimal very easily in javascript
Installation
Use npm to install js-ib-bits.
npm install js-in-bits
Usage
// Main functionsconst hexadecimalbinaryoctal = # returns '0xAA' # returns 'AA' # returns '5C' # returns '10101010' # returns '0010_0010_1111_1111_1010_1010_1011_1000' # returns '11001000' # returns '111' # return '200' # returns '144' # returns '12412' /* NOTE:: In case you don't determine the type of number(second argument)that you want to convert it in "hexa()" | "binary()" be care that number will be treated as "decimal" */ /* NOTE:: In case you don't determine the type of number(second argument)that you want to convert it in "decimal()" be care that number will be treated as "binary" */ /* NOTE:: In case you don't determine the type of number(second argument)that you want to convert it in "octal()" be care that number will be treated as "decimal" */ # returns '9A2112' # returns 4 // Extra functions const isDecimalisBinaryisHexa = # returns true # returns false # returns true # returns true # returns false # returns false # returns true # returns true # returns false
Arguments
Functions
- hexa(number,type,contain_ox),
- binary(number,type,separate_with_underScore),
- decimal(number,type)
- octal(number,type)
number: that number you want to convert it (required)
type: type of number you want to convert it (required when a number can be represented in two formats)
contain_ox: print the return value from hexa() concatenating with 0x (optional)
separate_with_underScore: separate the return value from binary() aftey every 4-digits (optional)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.