|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-10-26 03:19 UTC] hermawan at dmonster dot com
When I try to mod some integer, it returns false value, it's different with the calculator. Here is the example :
<?php
$int = 700000000;
$modwith = 1000000000000;
print $int%$modwith; // it return 700000000
// this is correnct.
$int = 800000000;
print $int%$modwith; // it return 72620032
// this is false, it supposed to be 800000000
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 02:00:01 2025 UTC |
I found the replacement of mod (%) which can be used with out of range value. The function is : function mod ($a, $b) { $rtn = $a; while ($rtn > $b) { $rtn -= $b; } return $rtn; } It works with my other script and returning the correct value. Please try it.