On Tue, 3 Sep 2002, Angus Leeming wrote: > The setw() call above should obviously be passed the required number of > digits. Given the number of snippets, nsnippets, what's the elegant way to > get ndigits? This is clearly brain-dead: > > ndigits = 1 + int(log10(double(nsnippets))); > > but I'm obviously suffering from BSE today.
int i = 0; while(nsnippets =>> 1) { ++i; } ndigits = 1 + i / 3; That is, the above is an integer approximation of : ndigits = ceiling(log2(nsnippets)/log2(10)); If you have a counter you're incrementing for each preview then surely you can output, preview1, preview2, ..., preview1984 etc. by just using a strstream to create the filename: fname << "preview" << current_snippet << ".eps"; or some such? Allan. (ARRae)