Quote Originally Posted by Kisen View Post
This looks much more condensed than how i have gone about it.
Does this method have much benefit in speed? Or is it just less typing?
In essence it is the same thing. I've only notice that any comparison results in 0 or 1 (not other values)... The if:
Code:
bin = n & 0x80;  // isolate bit 7.
if ( bin == 1)
  s[i] = '1';
else
  s[i] = '0';
Can be substituted by a single line:
Code:
s[i] = '0' + ( ( n & 0x80 ) != 0 );
As for the generated code by the compiler, with optimizations turned on, both codes are the same.

And, since s points to the beggining of the string, I use it...

BTW: There is an error in my routine. Before returning it should have:
Code:
  ...
  *s = '\0';  // puts the end of string mark.
}