php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14244 A bug about integer operation "/"
Submitted: 2001-11-27 01:06 UTC Modified: 2001-11-28 20:17 UTC
From: poolshark at bmcc dot com dot cn Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0.6 OS: linux
Private report: No CVE-ID: None
 [2001-11-27 01:06 UTC] poolshark at bmcc dot com dot cn
Here is a short test program :
<?
#test.php of integer operation by /
  $total=13;
  printf ("total %d  type %s<BR>",$total,gettype($total));
  $each=10;
  printf ("each %d  type %s<BR>",$each,gettype($each));
  $page=$total/$each;
  print ("Page is $page");
?>

The output is 1.3
not as the expect 1
-----------------------------
configure command

./configure --with-apache=/home/zlq/bin/apache_1.3.22
--with-mysql=/mysql
--with-xml
--with-charset=gb2312
--disable-debug
--enable-ftp


-------------------------------
INIT_VERSION :sysinit-2.78
HOSTTYPE:i386

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-27 01:16 UTC] cnewbill@php.net
RTM http://www.php.net/manual/en/language.operators.php

"The division operator ("/") returns an integer value (the result of an integer division) if the two operands are integers (or strings that get converted to integers) and the quotient is an integer. ****If either operand is a floating-point value, or the operation results in a non-integer value, a floating-point value is returned.****"

-Chris
 [2001-11-27 02:17 UTC] poolshark at bmcc dot com dot cn
Bug Database <php-dev@lists.php.net> 

Did you see my program?,and dir you run them?
obviously, the two operands are ***integers ***.
 [2001-11-27 04:08 UTC] derick@php.net
Again:

****If either operand is a
floating-point value, or the operation results in a non-integer value, a
floating-point value is returned.****

The division returns a floatingpoint value.
 [2001-11-27 04:11 UTC] cnewbill@php.net
Yes, did you read the part in ****?  Obviously not.

****If either operand is a floating-point value, or the operation results in a non-integer value, a floating-point value is returned.****

The operation 13/10 will result in 1.3 which is a float, so a floating point value is returned.

-Chris
 [2001-11-28 20:17 UTC] poolshark at bmcc dot com dot cn
************ Ignoring my bug report!!!! ***********
It is my wrong.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 02:01:23 2020 UTC