2 << -1 = 0?

Started by
10 comments, last by BradDaBug 20 years, 8 months ago
quote:Original post by Village Specialton
I don''t like #define. I prefer to use a variable. The books I read say to never use #define.

Scott Simontis
Big Joke: C#


Purists don''t want you to #define. But purists would rather write 20 lines of code where one would suffice, for the sake of purity. There are times when macros are appropriate.

I like pie.
[sub]My spoon is too big.[/sub]
Advertisement
But this isn''t one of those times.

unsigned pow2(unsigned n) { return 1 << n; }
will be identical to the macro. You may need to add the keyword "inline" if your optimizer is picky.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/

This topic is closed to new replies.

Advertisement