Re: A C Question.
On Tue, 17 Jan 2006 20:58:20 -0500, in comp.lang.c , Eric Sosman
<esosman@acm-dot-org.invalid> wrote:
[color=blue]
>Jack Young wrote:[color=green]
>> Hi:
>> There is question about C programming:
>> Use just one C statement to check whether a variable is the power of 2. No
>> loops allowed.[/color][/color]
Homework question...
[color=blue]
> int is_power_of_two (double x) {
> return x > 0.0; /* one statement, no loops */
> }[/color]
Cute. He probably meant an *integer* power? :-)
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
On Tue, 17 Jan 2006 20:58:20 -0500, in comp.lang.c , Eric Sosman
<esosman@acm-dot-org.invalid> wrote:
[color=blue]
>Jack Young wrote:[color=green]
>> Hi:
>> There is question about C programming:
>> Use just one C statement to check whether a variable is the power of 2. No
>> loops allowed.[/color][/color]
Homework question...
[color=blue]
> int is_power_of_two (double x) {
> return x > 0.0; /* one statement, no loops */
> }[/color]
Cute. He probably meant an *integer* power? :-)
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Comment