php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52566 Division by zero when using % operator.
Submitted: 2010-08-09 01:16 UTC Modified: 2010-08-09 17:42 UTC
From: eagls at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.3 OS: Windows Xp SP3
Private report: No CVE-ID: None
 [2010-08-09 01:16 UTC] eagls at yahoo dot com
Description:
------------
 Asume $f[1] = ""

I get a "Division by zero" error when i do this:

$overflowsimulation = (((strlen($f[1])) + 2147483648) % 4294967296);


In fact, i get it even if i do this:

$overflowsimulation = (2147483648 % 4294967296);

Thanks.

Test script:
---------------
<?php

$f = "";

$osim = (((strlen($f)) + 2147483648) % 4294967296);

echo $osim;

?>

Expected result:
----------------
0

Actual result:
--------------
Warning: Division by zero in C:\Archivos de programa\EasyPHP-5.3.2i\www\BASICtoPHP_testfile_60661.578.php on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-09 11:32 UTC] aharvey@php.net
-Status: Open +Status: Bogus -Package: *Regular Expressions +Package: Scripting Engine problem
 [2010-08-09 11:32 UTC] aharvey@php.net
On a 32 bit compile of PHP, 4294967296 used in an integer context will overflow to 0, hence PHP believes you're attempting to divide by 0, remembering that modulus is effectively division.

Expected behaviour; closing.
 [2010-08-09 17:42 UTC] eagls at yahoo dot com
-: elicon31@hotmail.com +: eagls at yahoo dot com
 [2010-08-09 17:42 UTC] eagls at yahoo dot com
just testing
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC