Version of php's base_convert without the internal "double" or "float" type restrictions.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
baseconvert.php
readme.md
test.php
unfucked_base_convert.php

readme.md

baseconvert

Description

Converts any string of any base to any other base without PHP native method base_convert's double and float limitations.

Instructions

Include the baseconvert.php in your script then call baseconvert() with the same parameters as PHP's base_convert.

License

Do whatever you want with it. Credit Michael Renner and I if you want or don't.

About

baseconvert returns false when

$Value is invalid for the $FromBase
62 < $FromBase < 2 That means $FromBase is less 2 or greater than 62 for math geniuses.
62 < $ToBase < 2 That means $ToBase is less 2 or greater than 62 for math geniuses.

Michael Renner's unfucked_base_convert doesn't do any checking at all and will always convert.

PHP's base_convert removes digits from $Value that aren't in $FromBase then continues as if nothing is wrong.


base_convert is obviously the fastest because it is a native method.
unfucked_base_convert is much slower when doing conversions en mass but doesn't suffer from base_convert's double and float limitations.
baseconvert is a little slower than unfucked_base_convert because of the parameter validation but the difference in neligible when compared to the native method.