konversi-bilangan
Table of contents
Instalasi
- Menggunakan yarn:
$ yarn add konversi-bilangan
- Menggunakan npm:
$ npm install konversi-bilangan
Cara Penggunaan
import Konversi from 'konversi-bilangan';
// Konversi desimal ke binner
console.log(new Konversi(12).toBinary()); // 1100
Parameter
new Konversi(angka: number | string, type: 'binary' | 'octal' | 'decimal' | 'hexadecimal' = 'decimal')
-
angka
- nilai yang ingin dikonversi -
type
- tipe angka, defaultdecimal
Functions
.toBinary()
.toOctal()
.toDecimal()
.toHexadecimal()
Examples
- Binary ke octal
console.log(new Konversi(1100, 'binary').toOctal()); // Outputs: 14
- Octal ke binary
console.log(new Konversi(14, 'octal').toDecimal()); // Outputs: 12
- Binary ke hexadecimal
console.log(new Konversi(12, 'decimal').toHexadecimal()); // Outputs: C
- Hexadesimal ke octal
console.log(new Konversi('12D', 'hexadecimal').toBinary()); // Outputs: 100101101
Contributing
I would love for you to contribute to andrijunaedi/konversi-bilangan
, pull requests are welcome!
License
The scripts and documentation in this project are released under the MIT License