From kde-devel Wed Apr 26 20:03:13 2006 From: Dmitry Suzdalev Date: Wed, 26 Apr 2006 20:03:13 +0000 To: kde-devel Subject: [OFFTOPIC] std::numeric_limits::min() question. Message-Id: <200604270003.13980.dimsuz () gmail ! com> X-MARC-Message: https://marc.info/?l=kde-devel&m=114608188806431 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 <<