php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6408 Large integer arithmetic broken
Submitted: 2000-08-28 19:24 UTC Modified: 2000-09-02 06:39 UTC
From: opoplawski at cqg dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: UnixWare 7.1.0
Private report: No CVE-ID: None
 [2000-08-28 19:24 UTC] opoplawski at cqg dot com
The following script gives the wrong answer:

<?php
$var1 = 3232300816;
$var2 = 256;
$var3 = $var1 % $var2;
print "$var1 % $var2 = $var3";
?>

Output is:

3232300816 % 256 = 0

Correct answer is 16.  This appears to be a consistent error, perhaps above the maximum for a 32-bit signed int?

Documentation doesn't seem to describe the limits, but this is all 32-bit.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-02 06:39 UTC] derick@php.net
With PHP int's are 32 bit signed numbers. If you need larger numbers, use the arbritary precision functions instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 16:01:35 2024 UTC