DECHEX(3) 1 DECHEX(3)dechex - Decimal to hexadecimalSYNOPSIS
string dechex (int $number)
DESCRIPTION
Returns a string containing a hexadecimal representation of the given unsigned $number argument.
The largest number that can be converted is PHP_INT_MAX
* 2 + 1 (or -1): on 32-bit platforms, this will be 4294967295 in decimal, which results in dechex(3) returning ffffffff.
PARAMETERS
o $number
- The decimal value to convert. As PHP's integer type is signed, but dechex(3) deals with unsigned integers, negative integers
will be treated as though they were unsigned.
RETURN VALUES
Hexadecimal string representation of $number.
EXAMPLES
Example #1
dechex(3) example
<?php
echo dechex(10) . "
";
echo dechex(47);
?>
The above example will output:
a
2f
Example #2
dechex(3) example with large integers
<?php
// The output below assumes a 32-bit platform.
// Note that the output is the same for all values.
echo dechex(-1)."
";
echo dechex(PHP_INT_MAX * 2 + 1)."
";
echo dechex(pow(2, 32) - 1)."
";
?>
The above example will output:
ffffffff
ffffffff
ffffffff
SEE ALSO hexdec(3), decbin(3), decoct(3), base_convert(3).
PHP Documentation Group DECHEX(3)
Check Out this Related Man Page
HEXDEC(3) 1 HEXDEC(3)hexdec - Hexadecimal to decimalSYNOPSIS
number hexdec (string $hex_string)
DESCRIPTION
Returns the decimal equivalent of the hexadecimal number represented by the $hex_string argument. hexdec(3) converts a hexadecimal string
to a decimal number.
hexdec(3) will ignore any non-hexadecimal characters it encounters.
PARAMETERS
o $hex_string
- The hexadecimal string to convert
RETURN VALUES
The decimal representation of $hex_string
EXAMPLES
Example #1
hexdec(3) example
<?php
var_dump(hexdec("See"));
var_dump(hexdec("ee"));
// both print "int(238)"
var_dump(hexdec("that")); // print "int(10)"
var_dump(hexdec("a0")); // print "int(160)"
?>
NOTES
Note
The function can convert numbers that are too large to fit into the platforms integer type, larger values are returned as float in
that case.
SEE ALSO dechex(3), bindec(3), octdec(3), base_convert(3).
PHP Documentation Group HEXDEC(3)
Hello guys!
Can say me anybody about operatios with unix, I don't to make operations, only inside in a variable, like this
#y=4
#x=2
#let z=$y-$x
#echo $z
# 2
but I can't to make mathematical operations with decimal like this
#y=3.2
#x=1.5
#let z=$y-$x
#echo $z
# 3
this... (2 Replies)
Hi frnds :)
I need a small help...
I have a very long file containing 20 digits decimal number which i want to convert into the corresponding 16 digit hexadecimal values.
File looks like....
11908486672755551741
05446378739602232559
04862605079740156652
.
.
.
I tried the script
for i... (7 Replies)
Hi all,
I'm trying to convert a decimal number into an integer number; I'm doing this:
n=`echo |awk '{ print "'"$mem"'"*10}'`
where the variable mem is equal to 3.7
I'd like to obtain 37, but the expression above gives me 30.
Help please!!!!
thx a lot (4 Replies)
How can I evaluate a decimal value in an if statement?
echo "Enter limit:"
read limit (enter a decmal value, ie: 2.5)
decimallimit=`echo $limit+0|bc|quit`
echo $decimallimit
if
then
echo $decimallimit
else
echo "failed"
fi (4 Replies)
Hi,
I would like to output the identical line to 2 text files, ie
output='blah'
echo $output > test1.txt
echo $output > test2.txt
Is there a way I could do that output with ONE command, ie
output='blah'
echo $output > test1.txt & test2.txt (I know that doesn't work)
Thanks for any... (1 Reply)
Hi all,
I have a small script to convert my HexaDecimal Input to Decimal as output.
#!/bin/ksh
hd=00208060
dec=`printf %d $hd`
echo $dec
Output of the above program:
printf: 00208060 not completely converted
16
But my expected output is "2130016".
How can i acheive this.
I... (2 Replies)
I have a log file that I am trying to convert. File contents something like this:
aaaaa bbbbbb cccc dddddd\123 eeeee ffffffff
I am trying to output the fields in a different order and separate field 4 so that the "123" and "dddddd" can be output separately. for example
bbbbbb aaaaa 123... (5 Replies)
OS - AIX 6.1
I am have below entry in my .profile
DS_LIB=/opt/IBM/InformationServer/Server/DSEngine/bin
export DS_BIN
When I do echo $DS_BIN, echo is returning empty
$ echo $DS_BIN
$
I never had this kind of issue earlier, please help me.
Thanks
srimitta (4 Replies)
Hi All,
Just faced an interesting thing in HP-UX. I was dividing 2955334616 / 2 by using echo `expr 2955334616 / 2` , and this ofcourse which expects 1477667308 to be returned. But I am getting -669816340 and I am :wall: how exactly this is possible. It is not one of the compliments (Ones or... (4 Replies)
I have a text file of alphanumeric values listed one by one. I have to convert them to hexadecimal equivalents for each character seperated by ":" in Unix bash shell script. For example, 12345678 has to be converted to 31:32:33:34:35:36:37:38 (10 Replies)
Hi
I tried giving the following command
echo $$a
I got an output like 32178a
Can some one please explain why echo $$ is returning 32178
Thanks in advance (6 Replies)
I need code for converting a string to a negative decimal value.
For ex, i have the value in the form of a string (5489.95-) i need to convert it into decimal value (-5489.95) while getting output using printf command.
i know how to get as a string
a="5489.95-"
printf "%10s"$a >>xyz.dat
... (5 Replies)