ID:               39703
 Comment by:       tayloj1 at uk dot ibm dot com
 Reported By:      arjen at parse dot nl
 Status:           Open
 Bug Type:         Documentation problem
 Operating System: Linux
 PHP Version:      Irrelevant
 New Comment:

Ref:  "The division operator ("/") returns a float value anytime, even
if the two operands are integers (or strings that get converted to
integers)." 

The word "anytime" is ambiguous. If "anytime" means "always" in this
context, the statement is not true as the following testcase shows:

<?php
$a = 4;
$b = 2;
$c = $a / $b;
var_dump($a, $b, $c); 
?>

Actual Output:
int(4)
int(2)
int(2)

Expected Output (if what the manual says were true) :

int(4)
int(2)
float(2) 

Also noting user comment from justin at koivi dot com, 25-Jan-2005,
suggest the existing sentence is replaced with the following text:  


"The division operator "/" returns a float value unless the two
operands are integers (or strings that get converted to integers) and
the numbers are evenly divisible, in which case an integer value will be
returned."


Previous Comments:
------------------------------------------------------------------------

[2006-12-01 14:06:46] arjen at parse dot nl

Description:
------------
http://www.php.net/manual/en/language.operators.arithmetic.php

"The division operator ("/") returns a float value anytime, even if the
two operands are integers (or strings that get converted to integers)."

Anytime like 'always' or 'it might be possible the division operator
returns a float, even if the operands are integers'?

Reproduce code:
---------------
<?php
echo gettype(10/2);
?>

Expected result:
----------------
float

Actual result:
--------------
integer


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39703&edit=1

Reply via email to