Re: PHP 4.0 Bug #5139 Updated: Subtraction among float-point numbers

From: Date: Tue, 20 Jun 2000 09:17:08 +0000
Subject: Re: PHP 4.0 Bug #5139 Updated: Subtraction among float-point numbers
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-21801@lists.php.net to get a copy of this message
Thanks for your instant response. And my new question is that what's the difference between the following two statements? <? echo (692.00-672.68-14.70); #4.6200000000001 echo (692.00-(672.68+14.70));#4.62 ?> Why do they have different results? Why does PHP display different digits for the same float-point value? What rule does PHP obey when display a float-point value? Best Regards, Eric Bug Database wrote: > ID: 5139 > Updated by: stas > Reported By: duxy@leyou.com > Status: Closed > Bug Type: Scripting Engine problem > Assigned To: > Comments: > > Not a bug. That's how FP works. Try doing this in Perl, C > or anything - you will get the same,given enough precision. > If you want to display only 3 digits, display only 3 digits. > PHP uses your C implementation of floating point. > > Full Bug description available at: > http://bugs.php.net/version4/?id=5139 -- Eric Du ----------------------------------- Tel: (86-010) 64181818-821 Fax: (86-010) 64181385 Leyou WebSite: http://www.leyou.com

« previous php.dev (#21801) next »