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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 + 45 = ?
Subscribe to this entry?

 
 [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: Sun Mar 03 23:01:32 2024 UTC