Re: Bug?

From: Date: Wed, 08 Aug 2001 09:35:36 +0000
Subject: Re: Bug?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-61786@lists.php.net to get a copy of this message
On Wed, Aug 08, 2001 at 07:18:26PM +1000, ReDucTor wrote: > if you use > echo (float)((8.85-8)*100); > it works because 8.85 go's to 0.85 and times that by 100, and you get 85 > which is what you get... Maybe you've heard about dynamic pages and stuff... Say: $a = 8.85; $b = 8; $c = 100; $result = (int)(($a-$b)*$c); And you know... we need an integer. Let's say for inserting into a db or so. Then it doesn't help converting it to float, does it? I mean... ofcourse in the above example it returns the correct result, but let's just change it a bit: $a = 8.8512; $b = 7.1237; $c = 100; $result_i = (int)(($a-$b)*$c); $result_f = (float)(($a-$b)*$c); See the diff between $result_i and $result_f? And if you realy need an integer, $result_f isn't realy what you're looking for. -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- H: +31 23 5516190 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#61786) next »