php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #8250 % calculation error
Submitted: 2000-12-14 04:22 UTC Modified: 2000-12-14 04:55 UTC
From: erwinba at 163 dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3 OS: Linux
Private report: No CVE-ID: None
 [2000-12-14 04:22 UTC] erwinba at 163 dot net
Reference this program :
$aa=3123456789;
$bb = $aa % 1000000000;
echo "$aa,$bb<br>\n";
$aa=3123456789;
$cc = $aa - floor($aa/1000000000)*1000000000;
echo "$aa,$cc<br>\n";

The result like the following :
3123456789,-147483648
3123456789,123456789

Because $aa is a bigint, so $bb will return a negative,
but the $cc is a normal result.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-14 04:55 UTC] stas@php.net
You cannot reliably do integer operations on numbers that do
not fit signed long. Use GMP extension for that.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 16:01:29 2024 UTC