Re: Automatically rounding numbers?

From: Date: Wed, 18 Oct 2006 15:46:48 +0000
Subject: Re: Automatically rounding numbers?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-243293@lists.php.net to get a copy of this message
On Wed, October 18, 2006 9:58 am, Tijnema ! wrote: > How can i disable the automatically rounding of numbers, as i work > with > large numbers and when i make them small again, it seems that the last > digits are gone. > example: > 12345678901234567890 > becomes: > 1.2345678901234E+19 = 12345678901234000000 > > Is there a way to disable this?? Sort of. You have not just one, but TWO options: http://php.net/gmp (newer, sexier, nicer) http://php.net/bc (older, bound to be installed everywhere) You have to change all your code to use the functions instead of your normal operators + - * / etc. These are going to be slower than the normal operators. GMP is "smart" and uses normal math for "small" numbers, if I'm reading the docs correctly. I would presume that in some cases, with large sets of data already using specialized database types, it would make more sense to just do ALL the arithmetic, no matter how trivial, in the DB. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#243293) next »