You are here: Re: how does this work « PHP Programming Language « IT news, forums, messages
Re: how does this work

Posted by Steve on 04/24/06 13:53

On Fri, 21 Apr 2006 11:20:27 +0100, Tim Martin wrote:

> milahu wrote:
>> Tim Martin wrote:
>>> milahu wrote:
>>>> IMO, the most odd thing about this is the single "&" between the two
>>>> statements; I would use "&&" or "and" here. ;)
>>> Why would you do that? '&&' and '&' are completely different operators,
>>> and give different results when evaluated in boolean context on two numbers.
>>
>> Because I prefer comparing boolean values with logical instead of byte
>> operators.
>>
>
> Sorry, I misread you. I thought you were referring to replacing the
> second '&', not the first one. I didn't even spot that the two boolean
> expressions were being combined with a bitwise operator (which I agree
> is wrong).
>
> For reference, the function in question was:
>
> function is_even($num){
> return (is_numeric($num)&(!($num&1)));
> }
>
>
> Tim

Why is it wrong? you're anding 0 or 1 with 0 or 1, and that'll return 1
only if both are 1. It might even be faster - probably not though.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация