You're viewing a comment by Jens Bauer and its responses.
You're viewing a comment by Jens Bauer and its responses.
I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
I am being sponsored by A-Writer! If you ever need help with essay writing, look no further than A-Writer! They will help you with your writing in as quickly as 3 hours!
I love to read science books. They make my day and I get ideas for awesome blog posts, such as Busy Beaver, On Functors, Recursive Regular Expressions and many others.
Take a look at my
Amazon wish list, if you're curious about what I have planned reading next, and want to surprise me. :)
If you are interested in advertising on catonmat.net, contact me.
Free tools for coding on Vietstarsoft.com.
Programming homework help.


Two minor things I've used a few times on my Atari ST, when I needed to count through a mask, leaving some bits as they were:
-This is a simple version:
Count up:
Count down:
You may find it useful for microcontrollers and output ports (welll... actually also mixed ports where some of the pins are inputs).
Sherif - Your 'exchange' is great. I'd prefer using it directly without function call, to eliminate the pointer stuff and the overhead of call/ret.
Someone once said to me: "you can't write a CRC calculation routine in C without a temp variable". The exchange above would make it possible.
I've used something similar...
c = *s++; if(13 == c || 10 == c) // if end of line { if((c ^ 13 ^ 10) == s[0]) // if oposite character is following; eg CR/LF or LF/CR { s++; // skip that char } }To convert a digit to a binary number:
if('1' == (c | 1)){ digit = c & 1; }octal...
if('7' == (c | 7)){ digit = c & 7 }Oh, and instead of doing for instance...
Why not use..
To detect a carry, when you don't have the carry bit available:
This works because b can be max. 255. A can be max. 255. (255+255) & 255 = 254, which is smaller than the previous value.
Same thing for subtracting; just check for a > prev_a than, instead of a < prev_a.
Reply To This Comment