Re: [RFC] [Discussion] Support object type in BCMath

From: Date: Wed, 27 Mar 2024 07:07:27 +0000
Subject: Re: [RFC] [Discussion] Support object type in BCMath
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-122772@lists.php.net to get a copy of this message
On 27.03.2024 01:03, Saki Takamachi wrote:
$num = new BcNum('1.23', 2); $result = $num + '1.23456'; $result->value; // '2.46456' $result->scale; // ??
In this case, $result->scale will be '5'. I added this to the RFC.
I'm not sure I like this. Maybe we should be more strict here and treat the $scale in constructor (and later withScale()) as the actual scale for all operations. So, in the case above I'd expect ->scale to be 2, and ->value to be '2.46'. If I wanted $num to have a scale that may change, I'd not define it in the first place. Does that make sense? ps. that also means withScale(null) should be possible. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com

« previous php.internals (#122772) next »