[PHP-DEV] Re: Bug # 13551, bcmath scale:: when to apply

2003-02-04 Thread Sara Golemon
 Indeed I wasn't aware of this bug report. It seems as if your patch is fine
 although I could only look at it briefly.
 It does look strange that you need to initialize the resulting scale
 manually. I thought the BC functions are supposed to take care of returning
 the results as the right scale.

The BC functions will predeict the required scale of the output, but the
numbers have to be in bc_num format going in and str2num requires that you
specify a scale.

 In any case, it probably makes sense for you to go ahead and commit it.

Will do.

 BTW, is php_str2num() only supposed to work on whole or decimal values?
 What about exponents?

bc_str2num() only allows whole or decimal values so that's all I wrote
php_str2num to allow for.
By 'exponents' do you mean scientific notation?  I don't see any support
for that in the bc conversion functions.  I don't suppose it would take
much to add that capability, but that'd be a feature change and should
probably be done separately (and only in HEAD).

-Pollita




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: Bug # 13551, bcmath scale:: when to apply

2003-02-04 Thread Andi Gutmans
At 11:31 AM 2/4/2003 -0800, Sara Golemon wrote:


 BTW, is php_str2num() only supposed to work on whole or decimal values?
 What about exponents?

bc_str2num() only allows whole or decimal values so that's all I wrote
php_str2num to allow for.
By 'exponents' do you mean scientific notation?  I don't see any support
for that in the bc conversion functions.  I don't suppose it would take
much to add that capability, but that'd be a feature change and should
probably be done separately (and only in HEAD).


Nah, if it doesn't support scientific notation then I'd leave it.
IMO, just go ahead and commit.
Andi


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: Bug # 13551, bcmath scale:: when to apply

2003-02-03 Thread Andi Gutmans
Hi,

Indeed I wasn't aware of this bug report. It seems as if your patch is fine 
although I could only look at it briefly.
It does look strange that you need to initialize the resulting scale 
manually. I thought the BC functions are supposed to take care of returning 
the results as the right scale.
In any case, it probably makes sense for you to go ahead and commit it.
BTW, is php_str2num() only supposed to work on whole or decimal values? 
What about exponents? I think you're probably right but I just want to make 
sure you thought about it.
Thanks,

Andi


At 01:51 PM 2/3/2003 -0800, Sara Golemon wrote:
Andi,

  Nicos assigned this bug to you a month ago, but since I've seen no
activity (and it's entirely possible you didn't know he'd assigned it) I
went ahead and took a crack at it.  Would you care to give me the go
ahead to commit/close for you?  ...or tell me to mind my own bugs? :)

Patches against PHP_4_3 and HEAD can be found at:

http://frankenbox.alphaweb.net/test/php_4_3.bcmath.diff.txt

and

http://frankenbox.alphaweb.net/test/HEAD.bcmath.diff.txt

The idea being to automagically determine the scale of the input numbers
so that they are not truncated prior to the op.  Then, once the op has
been performed, reduce the scale to whatever was requested.

The result-n_scale = scale; line might look a little dangerous, but
since it only comes after lines which create 'result' with a scale of *at
minimum* 'scale' it means that 'result-n_scale' will always be = 'scale'
and hence assigning it to 'scale' will always result in a reduction (or no
change at all) and bc_num2str won't go looking in undefined sections of
the bc_num val.

-Pollita

P.S. - This one's for you sniper ;)



--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php