Doc #53523 [Wfx]: Missing documentation for edge case of abs() function.
| From: | pinja_kolada at yahoo dot com | Date: | Sun, 12 Dec 2010 03:10:26 +0000 |
| Subject: | Doc #53523 [Wfx]: Missing documentation for edge case of abs() function. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5657@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53523&edit=1
ID: 53523
User updated by: pinja_kolada at yahoo dot com
Reported by: pinja_kolada at yahoo dot com
Summary: Missing documentation for edge case of abs()
function.
Status: Wont fix
Type: Documentation Problem
Package: Documentation problem
Operating System: GNU/Linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Agree with you that it is not necessary to note that just on abs() page.
For edge case (I am not sure, but) I think that abs() is defined here :
ext/standard/math.c from line 263 in PHP 5.3.4 source and it's the only
case where, when you feed abs() an integer you get back double (which is
integer overflow handling).
Previous Comments:
------------------------------------------------------------------------
[2010-12-12 00:22:59] dtajchreber@php.net
Integer overflow is described here: http://tinyurl.com/38rusjo
It's not really an edge case. It's just how PHP handles overflow. None
of the
other pages that return an integer specifically talk about it and I
don't think
it's necessary to note just on the abs() page.
------------------------------------------------------------------------
[2010-12-11 23:45:19] pinja_kolada at yahoo dot com
Description:
------------
---
From manual page: http://www.php.net/function.abs
---
Currently return type is described as:
"The absolute value of number. If the argument number is of type float,
the return type is also float, otherwise it is integer (as float usually
has a bigger value range than integer)."
and should be something like:
"The absolute value of number. If the argument number is of type float,
the return type is also float, otherwise it is integer (as float usually
has a bigger value range than integer). If the argument is of type
integer with value of - PHP_INT_MAX - 1 (minimum signed integer value)
the return type is float due to integer overflow...."
It's an edge case, but can be source of confusion if type is important.
Test script:
---------------
$n = - PHP_INT_MAX - 1;
var_dump($n); // type - int
var_dump(abs($n)); // type - float
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53523&edit=1