std::numeric_limits::min() return the minimum positive value. you could try maxd = -1 if d will be non-negative. that will be pretty obvious what is going on. Cheers, Will On 4/26/06, Dmitry Suzdalev wrote: > Hello! > > Please, sorry for offtopic, I write here in hope that this question will be > quickly answered as it seems to be simple (and I lack some knowledge). > > I have a C++ code like this: > > double d = 0; > double maxd = std::numeric_limits::min(); > .... > while(...) > { > d = ....; > if( d > maxd) > { > maxd = d; > ..... > } > } > > I.e., i want 'if' to _always_ evaluate to true on _first_ iteration. > But it doesn't work! > Gdb shows me that after initialisation 'maxd' is a _positive_ (and of course > huge) value! > Isn't it meant to be negative (despite of how it's internally stored in > "internals")? :) > > Note, that if I change the second line to > > double maxd = - std::numeric_limits::max(); > > then all works as I expect! > But I'd rather do without such tricks and write the code that's straitforward > and less messy ;). > > What am I getting wrong? > Thanks in advance! :) > > Dmitry. > > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<