arithmatic operation inconsistant

From: Date: Thu, 28 Feb 2002 14:17:12 +0000
Subject: arithmatic operation inconsistant
Groups: php.general 
Request: Send a blank email to php-general+get-86601@lists.php.net to get a copy of this message
I have a very simple php page which I am creating an accounting tutorial from. I am writing all of the equations on an include file and then calling the file at the beginning of the appropriate pages My problems lie in inconsistant arithmatic operations. For some reason the equation for $gm1 does not always act as though $ns1 has a value. Only about 30% of the time does $gm1 give the number I expect to see. The rest of the time what I get is a negative (-$cogs1 +1). As if you had taken 1 and subtracted $cogs1. All help MUCH appreciated. srand ((double) microtime() * 1000000); #### Income statement $ns1=number_format(rand(900,1200)*1000) ; $cogs1=number_format(rand(450,600)*1000) ; $gm1=number_format (($ns1 - $cogs1) * 1000); Dr. Roy F. Cabaniss Associate Professor of Business University of Arkansas Monticello http://cabanisspc.uamont.edu/~rcaban

« previous php.general (#86601) next »