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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: eagls at yahoo dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 25 22:01:29 2024 UTC