Er - yes.
If you do conversion type you are correct. but in the example I showed I
didn't...
If you run the code bellow you will see...
bcscale( 10 );
$a = 14.5;
$b = -14.5;
$c = bcadd( $a, $b );
if( $c )
{
echo "true: c = ".$c."<br>";
} else
{
echo "false: c = ".$c."<br>";
}
var_dump((bool) "0");
It's a common use to do if( $var ) and not if( (bool)$var )...
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