Re: svn: /phpdoc/en/trunk/reference/strings/functions/chr.xml
| From: | Christoph Becker | Date: | Sun, 03 Jul 2016 17:25:02 +0000 |
| Subject: | Re: svn: /phpdoc/en/trunk/reference/strings/functions/chr.xml | ||
| References: | 1 2 3 4 5 | Groups: | php.doc.cvs |
| Request: | Send a blank email to doc-cvs+get-14281@lists.php.net to get a copy of this message | ||
On 02.07.2016 at 13:49, Christoph Becker wrote:
> On 02.07.2016 at 13:09, Nikita Popov wrote:
>
>> On Sat, Jul 2, 2016 at 12:56 PM, Christoph Becker <cmbecker69@gmx.de> wrote:
>>
>>> On 02.07.2016 at 12:48, Peter Cowburn wrote:
>>>
>>>> On 1 July 2016 at 21:07, Christoph Michael Becker <cmb@php.net> wrote:
>>>>
>>>>> cmb Fri, 01 Jul 2016 20:07:17 +0000
>>>>>
>>>>> Revision:
>>>>> http://svn.php.net/viewvc?view=revision&revision=339537
>>>>>
>>>>> Log:
>>>>> Address #63510: Integer overflow with chr
>>>>>
>>>>> Bug: https://bugs.php.net/63510 (Assigned)
>>>>> Integer overflow with chr
>>>>>
>>>>> Changed paths:
>>>>> U phpdoc/en/trunk/reference/strings/functions/chr.xml
>>>>>
>>>>> Modified: phpdoc/en/trunk/reference/strings/functions/chr.xml
>>>>> ===================================================================
>>>>> --- phpdoc/en/trunk/reference/strings/functions/chr.xml 2016-07-01
>>>>> 09:07:57 UTC (rev 339536)
>>>>> +++ phpdoc/en/trunk/reference/strings/functions/chr.xml 2016-07-01
>>>>> 20:07:17 UTC (rev 339537)
>>>>> @@ -29,7 +29,8 @@
>>>>> <term><parameter>ascii</parameter></term>
>>>>> <listitem>
>>>>> <para>
>>>>> - The ascii code.
>>>>> + A number which is bitwise and'ed with 255 to retrieve the
>>> extended
>>>>> ASCII
>>>>> + code.
>>>>> </para>
>>>>>
>>>>
>>>> This shouldn't be the primary description of the parameter, but rather a
>>>> second paragraph stating what happens with values outside the normal
>>> range.
>>>
>>> Thanks. I'll fix it later today.
>>>
>>
>> It might also help to rephrase this in terms of only using the lowest byte
>> or using "ascii % 256". I'm not sure if the significance of bitwise
>> operations on 2^n-1 values is common knowledge for PHP devs.
>
> Thanks for the suggestions. Indeed, $ascii&255 appears to be hard to
> understand for the average PHP developer, but "using the lowest byte"
> seems to be not much easier, particularly wrt. negative values.
> $ascii%256 is simple to understand, but doesn't explain the behavior of
> negative values. Actually, I can't think of an explanation that is easy
> to understand, yet still precise, short of
>
> while ($ascii < 0) {
> $ascii += 256;
> }
> $ascii %= 256;
>
> Suggestions are welcome!
Fixed with r339548.
--
Christoph M. Becker