On Wednesday 04 September 2002 6:52 am, Allan Rae wrote: > 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));
Thanks, Allan. I'll have to sit down and think about this. I'm totally useless when it comes to shift operations. > 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? Yes, true. I believe I went for fixed sizes to ensure that the actual gs output filename was the same as that expected by lyx. Of course, it may have been that I just wanted 'ls' to list them in order! Again, I'll experiment. Angus