On Sun, Oct 17, 2004 at 01:09:41PM +0000, Andreas Vox wrote: > Andre Poenitz <[EMAIL PROTECTED]> writes: > > > On Sun, Oct 17, 2004 at 12:26:40AM +0200, Andreas Vox wrote: > > > | + result += "0123456789" [ (i / digit) % 10 ]; > > > > Why not > > result += '0' + (i / digit) % 10 > > ? > > Because that is my general pattern for translating chars. > It works in all programming languages and is not limited > to digits or a character encoding.
This is guaranteed to work in any Standard conforming C or C++ compiler. > > Apart from that, 'digit' is a misnomer if the thing can be 1000. > > The only better name I coukd think of is 'digitPos' ... > > > The whole function can be replaced by 'toStr' from src/support/tostr.h. > > Grr, and I was searching for an 'itoa' function in the standard library The canonical C++ way to transform anything into a string is ... std::ostringstream os; os << the_thing; std::string str = os.str(); Our 'toStr' functions are only thin wrappers around this. Andre'