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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: erwinba at 163 dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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 Nov 03 08:01:28 2024 UTC