Re: [RFC] Floating Point support in GMP extension

From: Date: Thu, 24 Apr 2014 11:11:59 +0000
Subject: Re: [RFC] Floating Point support in GMP extension
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-73773@lists.php.net to get a copy of this message
Yes, now I understand better the sense in GMPInt, you are right that there should be different classes. We use BCMath, but bulky code BCMath: bcmul(bcadd($a, $b, $scale), 2, $scale) I want to write simple: $a + $b * 2 I'm looking forward to implementing GMPFloat 2014-04-24 11:17 GMT+03:00 Nikita Popov <nikita.ppv@gmail.com>: > On Mon, Apr 21, 2014 at 10:40 PM, Park Framework <park.framework@gmail.com > > wrote: > >> Concept is simple. >> Need, remove GMPInt, leave only GMPFloat. >> For backward compatibility in php.ini set default values >> ​​gmp.default_precision = 0 >> Anyone who wants to work with float, must specify precision > 0 >> What do you think about this? >> > > This is not possible, because GMP integers and GMP floats are > fundamentally and inherently different types. > > A GMP integer isn't just a GMP float with zero precision. Actually, what I > think you're missing here is that the GMP floating point type is just that: > A **floating** point type. This means that it is **not** precise. What you > specify as the GMP float precision actually translates to the size of the > mantissa/significand, not the number of places after the comma. > > GMP integers on the other hand are precises. Furthermore a primary > application for GMP integers are computations over cyclic groups, as well > as other number theoretic computations. The operations for these are not a > available for the floating point type (and frankly, wouldn't really make > sense). > > Maybe you're looking for the BCMath extension? > > Nikita >

« previous php.internals (#73773) next »