Re: Bug #15756 Updated: bad Subtraction

From: Date: Wed, 27 Feb 2002 09:52:53 +0000
Subject: Re: Bug #15756 Updated: bad Subtraction
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-80438@lists.php.net to get a copy of this message
You know, perhaps we should drop the default precision down from 14 a bit. I am getting tired of answering this one. Even dropping it to 12 would have prevented this particular question. Of course, people will never understand the real issue and will end up writing code that magnifies such precision errrors. Anybody think we would have BC issues going from 14 to 10? -Rasmus On 27 Feb 2002 rasmus@php.net wrote: > ID: 15756 > Updated by: rasmus@php.net > Reported By: jjulio@post.sk > -Status: Open > +Status: Bogus > Bug Type: *General Issues > Operating System: linux > PHP Version: 4.0.6 > New Comment: > > Please don't ask support questions in the bug database. > Computers can only approximate floating point numbers to a certain > level of precision. Simply set the precision you want. Try adding > this line before your echo lines: > ini_set('precision',4); > > > Previous Comments: > ------------------------------------------------------------------------ > > [2002-02-27 04:47:38] jjulio@post.sk > > When i use this code: > <? > echo 120-119.1."\n"; > echo 120-119.2."\n"; > echo 120-119.3."\n"; > echo 120-119.4."\n"; > echo 120-119.5."\n"; > echo 120-119.6."\n"; > echo 120-119.7."\n"; > echo 120-119.8."\n"; > echo 120-119.9."\n"; > ?> > or with variables...results was: > > 0.90000000000001 > 0.8 > 0.7 > 0.59999999999999 > 0.5 > 0.40000000000001 > 0.3 > 0.2 > 0.099999999999994 > > Is it correct or no? > > How can i get correct results without using round()??? > > > > ------------------------------------------------------------------------ > > > -- > Edit this bug report at ­U 0{àè > ñ6¨_.¶http://bugs.php.net/?id=15756&edit=1 >

« previous php.dev (#80438) next »