#23791 [Fbk->Bgs]: Mod doesn't return correct values

From: Date: Sun, 25 May 2003 09:52:26 +0000
Subject: #23791 [Fbk->Bgs]: Mod doesn't return correct values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40370@lists.php.net to get a copy of this message
ID: 23791 Updated by: derick@php.net -Summary: Mod does'nt return correct values Reported By: info at veebiteenused dot com -Status: Feedback +Status: Bogus Bug Type: Math related Operating System: RedHat Linux 9 PHP Version: 4.3.2RC4 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php PHP only supports signed integers (range is -2147483648 to 2147483647 on Linux), so this is actually the expected behavior. We do not 'upgrade' the number to a float automatically because that would be against the nature of the % operator: integer modulo. Previous Comments: ------------------------------------------------------------------------ [2003-05-24 20:07:27] michael dot mauch at gmx dot de <?php echo 2147483647 % 1000,"\n"; echo 2147483648 % 1000,"\n"; echo 2147483649 % 1000,"\n"; echo fmod(2147483648,1000),"\n"; ?> Output: 647 -648 -647 648 This is on 32 bit Linux. I'm not sure whether % is supposed to work with numbers bigger than LONG_MAX. No problem with long2ip here. ------------------------------------------------------------------------ [2003-05-24 18:04:51] derick@php.net I don't see any problem here, the script below produce the correct output: [derick@kossu derick]$ php-4.3.2RC4 <?php echo long2ip(3232238081); ?> 192.168.10.1 Please submit a valid script that reproduces this problem. Derick ------------------------------------------------------------------------ [2003-05-24 09:58:29] info at veebiteenused dot com long2ip(3232238081) = '192.168.10.-255' 3232238081 % 256 = -255 must be: 3232238081 % 256 = 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23791&edit=1

« previous php.bugs (#40370) next »