php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25650 Bad number return by % operator
Submitted: 2003-09-25 02:19 UTC Modified: 2003-09-25 10:14 UTC
From: jserrano at cutb dot edu dot co Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.3.1 OS: Mandrake 9.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jserrano at cutb dot edu dot co
New email:
PHP Version: OS:

 

 [2003-09-25 02:19 UTC] jserrano at cutb dot edu dot co
Description:
------------
the Operator % (modular division) return a erroneous result.

Reproduce code:
---------------
 $a = 63522;
 $b = 62186;
 echo "a = 63522\n";
 echo "b = 62186\n";
 echo $num."\n";
 $mod = ($a*$b) % 65536;
 echo "mod = $mod";


Expected result:
----------------
 $a = 63522;
 $b = 62186;
 $num = $a*$b;
 echo $num."\n";
 $p = $num/65536;
 echo (int)$p."\n";
 $num = $num-((int)$p*65536);
 echo "re-mod = $num";


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-25 10:14 UTC] pollita@php.net
63522 * 61826 is greater than the largest possible value for an integer on a 32-bit system (2147483647).

In order to work with values of this size you must either use the bcmath or gmp functions, or upgrade to a 64-bit processor.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC