Re: Re: is the bankers' round() algorithm implemented well?

From: Date: Mon, 07 Feb 2005 21:20:06 +0000
Subject: Re: Re: is the bankers' round() algorithm implemented well?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-14704@lists.php.net to get a copy of this message
On Mon, Feb 07, 2005 at 10:04:46PM +0100, Ron Korving wrote: > I just did a long test from 1 - 10000 and I noticed that every time the > number was increased with one bit (starting with 2048, then 4096, then 8192) > behaviour changes. You were right, my bad. > > Makes me wonder though, what's the point of a bankers' algorithm if .005 can > never be reached, only approached? :) This unpredictable rounding behaviour > is a real b*tch, but what can you do :) you want to use integers or bcmath (http://php.net/bc) or gmp (http://php.net/gmp) to get your own control of rounding and accuracy. this makes this thread more appropiate for php-general than for internals. greetings messju > Ron

« previous php.internals (#14704) next »