Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11949 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88240 invoked by uid 1010); 6 Aug 2004 01:01:52 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 88099 invoked from network); 6 Aug 2004 01:01:51 -0000 Received: from unknown (HELO wb2-a.mail.utexas.edu) (128.83.126.136) by pb1.pair.com with SMTP; 6 Aug 2004 01:01:51 -0000 Received: (qmail 44370 invoked from network); 6 Aug 2004 01:01:50 -0000 Received: from host113-1.discord.birch.net (HELO ?10.10.100.204?) (dr?mac@65.16.113.1) by wb2.mail.utexas.edu with SMTP; 6 Aug 2004 01:01:50 -0000 User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Thu, 05 Aug 2004 20:02:04 -0500 To: Message-ID: Mime-version: 1.0 jackstopper: harryPotter Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Subject: Modulo Function returns incorrect results From: dr_mac@mail.utexas.edu (Matthew Boehm) Found some weird behavior in the built in mod function (%): $a = 4; $b = 3; print ( $a % $b ); (returns 1 as it should) Now swap $a and $b: $a = 3; $b = 4; print ( $a % $b ); This returns 3. 3?! 3/4 is 0.75. Shouldn't this return 0? Try this one: $a = 20; $b = 10; print ( $a % $b ); Shouldn't that return 2? It returns 0; $a = 11; $b = 21; print ( $a % $b ); Returns 11. What is going on? Was my C.S. Professor wrong in telling us that the % function returns the left side of the decimal in a division? This is PHP 4.3.4 Any help would be appreciated. Thanks, Matthew -- ---------------------------------------------------------------------------- Matthew Boehm dr_mac@mail.utexas.edu The University of Texas at Austin, Department of Geography "Why did the prison use Windows2K as a guard? Because it always locks up!" ----------------------------------------------------------------------------