Lars Gullik BjÃnnes wrote: > Andre Poenitz > <[EMAIL PROTECTED]> > writes: > > | On Mon, Nov 29, 2004 at 02:36:47PM +0100, Lars Gullik BjÃnnes wrote: >>> Alfredo Braunstein <[EMAIL PROTECTED]> writes: >>> | // Find position closest to (x, y) in cell given by iter. >>> | + // Used only in mathed >>> | DocIterator bruteFind2(LCursor const & c, int x, int y) >>> | { >>> | double best_dist = 1e10; >>> >>> 1e10 is not good... (but not your code)... >> > | It is mine. >> >>> double best_dist = std::numeric_limits<double>::max(); >>> >>> would be a lot better. >> > | Well, better... amybe. A lot? > > Well... yes. > > It shows that you want to start the valua at max, not at some > arbitrary number. > > | I don't expect monitors with more than 100000 pixel resolution in either > | direction to turn up soonish.. >> >>> | + << " best: " << best_dist << endl; >>> | if (d <= best_dist) { >>> | best_dist = d; >>> >>> best_dist = min(best_dist, d); >> > | Why? > > At least in my op. it shows intent a lot better.
But note that there is more code inside that if block, so you cannot remove the "if". And if (d <= best_dist) { best_dist = min(best_dist, d); ... does look silly (to me). > | If I read such code I always mentally translate it to the other version. > | So at least for me this is certainly less readable. > > I am the opposite end. > And especially this last one where you can keep w const and initialize > once. I agree with Lars here. (still, I think that there are more interesting things to do than to discuss these details ;-) Regards, Alfredo