RE: [PHP] RE: question about ? :

From: Date: Wed, 19 Jun 2002 23:15:55 +0000
Subject: RE: [PHP] RE: question about ? :
Groups: php.general 
Request: Send a blank email to php-general+get-103038@lists.php.net to get a copy of this message
This one's straight forward 1. $x = 9 - 5 + 3; // 7 But let's expand this one 2. $x = 9 - (5 + 3); // 1 3. $x = 9 - 5 - 3; // different from 1. (simple algebra expansion...) -----Original Message----- From: Ford, Mike [LSS] [mailto:M.Ford@lmu.ac.uk] Sent: Wednesday, June 19, 2002 11:34 PM To: 'Joel Boonstra'; Ford, Mike [LSS] Cc: 'Lee Doolan'; php-general@lists.php.net Subject: [PHP] RE: question about ? : > -----Original Message----- > From: Joel Boonstra [mailto:jboonstra@gospelcom.net] > Sent: 19 June 2002 14:00 > > > OK, try this: why does > > > > $x = 3 + 5 - 7; > > > > produce different results from > > > > $x = 3 + (5 - 7); > > Really? It shouldn't produce different results for you -- they should > both evaluate to '1'. Jeez, you're right! That was dumb!! Somehow I suffered a brain-wibble that managed to calculate 5-7 as +2 rather than -2. As I studied maths all the way up to 1st year at university -- and do understand the rules of precedence and associativity, honest, boss -- I really shouldn't have made that kind of basic error. Still, the principle I was trying to illustrate is still good, even if my example was complete codswallop, so let's try again. Why does: $x = 9 - 5 + 3; // 7 produce a different result from: $x = 9 - (5 + 3); // 1 Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#103038) next »