base-convert
Convert an arbitrarily-long string from one numeric base to another, optionally zero-padding to a minimum column width.
|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. More...
Functions | |
Wikimedia::base_convert ( $input, $sourceBase, $destBase, $pad=1, $lowercase=true, $engine='auto') | |
Convert an arbitrarily-long string from one numeric base to another, optionally zero-padding to a minimum column width. | |
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html
Wikimedia\base_convert | ( | $input, | |
$sourceBase, | |||
$destBase, | |||
$pad = 1, | |||
$lowercase = true, | |||
$engine = 'auto' ) |
Convert an arbitrarily-long string from one numeric base to another, optionally zero-padding to a minimum column width.
Supports base 2 through 36; digit values 10-36 are represented as lowercase letters a-z. Input is case-insensitive.
string | $input | Input number |
int | $sourceBase | Base of the input number |
int | $destBase | Desired base of the output |
int | $pad | Minimum number of digits in the output (pad with zeroes) |
bool | $lowercase | Whether to output in lowercase or uppercase |
string | $engine | Either "gmp", "bcmath", "php" or "auto" (default). In the case of "auto", the other engines ("gmp" and "bcmath") are used in the listed order in terms of preference if that PHP extension is actually loaded. |