BASE_CONVERT(3) 1 BASE_CONVERT(3)base_convert - Convert a number between arbitrary basesSYNOPSIS
string base_convert (string $number, int $frombase, int $tobase)
DESCRIPTION
Returns a string containing $number represented in base $tobase. The base in which $number is given is specified in $frombase. Both $from-
base and $tobase have to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters
a-z, with a meaning 10, b meaning 11 and z meaning 35.
Warning
base_convert(3) may lose precision on large numbers due to properties related to the internal "double" or "float" type used. Please
see the Floating point numbers section in the manual for more specific information and limitations.
PARAMETERS
o $number
- The number to convert
o $frombase
- The base $number is in
o $tobase
- The base to convert $number to
RETURN VALUES
$number converted to base $tobase
EXAMPLES
Example #1
base_convert(3) example
<?php
$hexadecimal = 'A37334';
echo base_convert($hexadecimal, 16, 2);
?>
The above example will output:
101000110111001100110100
SEE ALSO intval(3).
PHP Documentation Group BASE_CONVERT(3)
Check Out this Related Man Page
GMP_STRVAL(3) 1 GMP_STRVAL(3)gmp_strval - Convert GMP number to stringSYNOPSIS
string gmp_strval (GMP $gmpnumber, [int $base = 10])
DESCRIPTION
Convert GMP number to string representation in base $base. The default base is 10.
PARAMETERS
o $gmpnumber
- The GMP number that will be converted to a string. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6
and later, or a numeric string provided that it is possible to convert the latter to a number.
o $base
- The base of the returned number. The default base is 10. Allowed values for the base are from 2 to 62 and -2 to -36.
RETURN VALUES
The number, as a string.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.2 | |
| | |
| | The $base was extended from 2 to 36, to 2 to 62 |
| | and -2 to -36. |
| | |
+--------+---------------------------------------------------+
NOTES
Note
To use the extended base introduced in PHP 5.3.2, then PHP must be compiled against GMP 4.2.0 or greater.
EXAMPLES
Example #1
Converting a GMP number to a string
<?php
$a = gmp_init("0x41682179fbf5");
printf("Decimal: %s, 36-based: %s", gmp_strval($a), gmp_strval($a,36));
?>
PHP Documentation Group GMP_STRVAL(3)
Hi
Can anybody tell me what is the meaning of the following code?
i=4 j=1 k=0
Specialy meaning of this line
echo $?
Specialy meaning of this line
echo $?
Specialy meaning of this line
echo $?
Thanks in advance
Sas (3 Replies)
hi ,
i need a script to convert number into hexadecimal base
for example: 237=>ED
it s very important for me thank you in advance for you help (5 Replies)
I'm having trouble breaking a string into four different numbers. What I'm starting out with is
foo='1218141 1441 1664 122222'
and what I want to have is
a=1218141
b=1441
c=1664
d=122222
I'm tried using some pattern matching to break the string up into these four different... (7 Replies)
can some one please tell the meaning of the second statement i.e
n=${m#*=}
i couldnt get the meaning of the #*=
1.) m="mohit=/c/main/issue"
echo $m
result
-----------
mohit=/c/main/issue
2.) n=${m#*=}
echo $n
RESULT
-------
/c/main/issue (1 Reply)
HI guys,
I need to check the base.txt file with the base.lck file and get a resulting base file which checks the last number in the base.lck file and starts with the number after the numbers in the base.lck file.
Here the base.txt is the list of numbers.
The base.lck file is something like a... (8 Replies)
I have a data base of part numbers:
AAA Thing1
BBB Thing2
CCC Thing3
File one is a list of part numbers:
AAA234
BBB678
CCC2345
Is there a sed one-line that would compare a data base with and replace the part numbers so that the output looks like this?
AAA234 Thing1
BBB678 Thing2... (5 Replies)
Hello Guys,
I'm new in programing line & just started from C++ programs but i don't know the meaning of #include<stdio.h> file....Guys tell me what's the working of this file in C++ program?? I'm confused...
Title changed: Please use a descriptive subject text, and not C++?? (3 Replies)