Skip to content

A simple and efficient package to convert numbers to their binary equivalent using PHP

License

Notifications You must be signed in to change notification settings

delhombre/binary-converter

Repository files navigation

BinaryConverter PHP

GitHub Workflow Status (main) Total Downloads Latest Version License


BinaryConverter is a PHP library that converts binary numbers to decimal numbers and vice versa. It also supports hexadecimal conversion.

Get Started

Requires PHP 8.1+

First, install BinaryConverter via the Composer package manager:

composer require delhombre/binary-converter

Then, interact with the package:

$converter = BinaryConverter::from(2024);

$bin = $converter->toBinary();

dd($bin); // "11111101000"

You can pass the input as a string or as an integer.

dd(BinaryConverter::from('2024')->toBinary()); // "11111101000"

But sometimes you may want to convert a binary number to a decimal number. You can do it by passing the inputType parameter like this:

dd(BinaryConverter::from('11111101000', 'binary')->toDecimal()); // 2024

BinaryConverter PHP is an open-sourced software licensed under the MIT license.

About

A simple and efficient package to convert numbers to their binary equivalent using PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages