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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: opoplawski at cqg dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC