Re: PHP 4.2.2 Float->Mysql addition problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Actually we'r talking about diffrent things... What I wanted to highlight is that results that should be normally seen as 0 or false for logic comparations when using bc functions are not processed as 0 or false actually and you should take care when using constructs like

if( $var )
{
   ...
}

when working with variables that are a result of bc functions.

	Andy

Ford, Mike wrote:
On 03 February 2006 13:14, Andrei wrote:

Welcome,
Please note that using bc function variables will be of type string.
So a code working with numeric values like:

$a = 1;
if( $a )
{
     ...
}

it's ok but with bc functions:

$a = 14.5;
$b = -14.5;
$c = bcadd( $a, $b );
if( $c )
{
    ...
}

will not work as expected ( if( "0" ) is interpreted like a string
that is not null and so condition is interpreted as true.

Er - nope.  The string "0" is explicitly equivalent to FALSE -- see http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux