Skip to content

Convert numbers between any base you want, including negative numbers and floatingpoint numbers

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
LICENSE.md
Notifications You must be signed in to change notification settings

smart-lib/base-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BaseConverter

Convert numbers between any base you want, including negative numbers and floating point numbers

  • Including default bases from 2 to 64 symbols
  • Convert from and to custom charset
  • Convert negative numbers
  • Convert floating point numbers(with delimiter, without exponent)
  • Customize minus sign and float delimiter

Install

Via Composer

$ composer require smart-lib/base-converter

Usage

Simple:

$converter = new SmartLib/BaseConverter();
echo $converter->convert('100500', 10, 36);
echo $converter->convert('-100500', 10, 36);
echo $converter->convert('100500.99', 10, 64);

Custom charset:

$converter = new SmartLib/BaseConverter();
echo $converter
    ->from(10)
    ->to(6, 'QWERTY')
    ->convert('100500', 10, 6);

Change delimiter, change minus sign:

$converter = new SmartLib/BaseConverter();
echo $converter
    ->from(10)
    ->to(36, null, ',', '~')
    ->convert('-100.500', 10, 36);

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The GPL-3.0 License. Please see License File for more information.

About

Convert numbers between any base you want, including negative numbers and floatingpoint numbers

Resources

License

GPL-3.0, GPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
GPL-3.0
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages