Re: PHP 4.2.2 Float->Mysql addition problem
| From: | Andrei | Date: | Fri, 03 Feb 2006 14:59:35 +0000 |
| Subject: | Re: PHP 4.2.2 Float->Mysql addition problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229808@lists.php.net to get a copy of this message | ||
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 ) {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@leedsmet.ac.uk...} 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.Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm