reference/math/functions/dechex.xml
0c9c2dd669fe9395eaa73d487fbd160f9057429a
...
...
@@ -7,14 +7,20 @@
7
7
</refnamediv>
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
-
<methodsynopsis>
11
-
<type>string</type><methodname>dechex</methodname>
12
-
<methodparam><type>int</type><parameter>number</parameter></methodparam>
13
-
</methodsynopsis>
10
+
<methodsynopsis>
11
+
<type>string</type><methodname>dechex</methodname>
12
+
<methodparam><type>int</type><parameter>num</parameter></methodparam>
13
+
</methodsynopsis>
14
14
<para>
15
-
Returns a string containing a hexadecimal representation of the
16
-
given <parameter>number</parameter> argument. The largest number that can
17
-
be converted is 4294967295 in decimal resulting to "ffffffff".
15
+
Returns a string containing a hexadecimal representation of the given
16
+
unsigned <parameter>num</parameter> argument.
17
+
</para>
18
+
<para>
19
+
The largest number that can be converted is
20
+
<constant>PHP_INT_MAX</constant><literal> * 2 + 1</literal> (or
21
+
<literal>-1</literal>): on 32-bit platforms, this will be
22
+
<literal>4294967295</literal> in decimal, which results in
23
+
<function>dechex</function> returning <literal>ffffffff</literal>.
18
24
</para>
19
25
</refsect1>
20
26
<refsect1 role="parameters">
...
...
@@ -22,10 +28,15 @@
22
28
<para>
23
29
<variablelist>
24
30
<varlistentry>
25
-
<term><parameter>number</parameter></term>
31
+
<term><parameter>num</parameter></term>
26
32
<listitem>
27
33
<para>
28
-
Decimal value to convert
34
+
The decimal value to convert.
35
+
</para>
36
+
<para>
37
+
As PHP's <type>int</type> type is signed, but
38
+
<function>dechex</function> deals with unsigned integers, negative
39
+
integers will be treated as though they were unsigned.
29
40
</para>
30
41
</listitem>
31
42
</varlistentry>
...
...
@@ -35,7 +46,7 @@
35
46
<refsect1 role="returnvalues">
36
47
&reftitle.returnvalues;
37
48
<para>
38
-
Hexadecimal string representation of <parameter>number</parameter>
49
+
Hexadecimal string representation of <parameter>num</parameter>.
39
50
</para>
40
51
</refsect1>
41
52
<refsect1 role="examples">
...
...
@@ -60,6 +71,30 @@ a
60
71
</screen>
61
72
</example>
62
73
</para>
74
+
<para>
75
+
<example>
76
+
<title><function>dechex</function> example with large integers</title>
77
+
<programlisting role="php">
78
+
<![CDATA[
79
+
<?php
80
+
// The output below assumes a 32-bit platform.
81
+
// Note that the output is the same for all values.
82
+
echo dechex(-1)."\n";
83
+
echo dechex(PHP_INT_MAX * 2 + 1)."\n";
84
+
echo dechex(pow(2, 32) - 1)."\n";
85
+
?>
86
+
]]>
87
+
</programlisting>
88
+
&example.outputs;
89
+
<screen>
90
+
<![CDATA[
91
+
ffffffff
92
+
ffffffff
93
+
ffffffff
94
+
]]>
95
+
</screen>
96
+
</example>
97
+
</para>
63
98
</refsect1>
64
99
<refsect1 role="seealso">
65
100
&reftitle.seealso;
...
...
@@ -73,7 +108,6 @@ a
73
108
</para>
74
109
</refsect1>
75
110
</refentry>
76
-

77
111
<!-- Keep this comment at the end of the file
78
112
Local variables:
79
113
mode: sgml
80
114