On Samstag, 2. Januar 2021 12:44:31 CET Dominik Haumann wrote:
> This is just by looking at the first two header files.
> 
> Looking at WeatherForecast.cpp:
> 
>     double maxTemp = std::numeric_limits<double>::min();
>     double minTemp = std::numeric_limits<double>::max();
> 
> Initializing the temperature to 0, 0, sounds a bit more sane to me, but
> that is disputable I guess.

Nice find. This looks quite familiar, the weather forecast accumulation code 
in Itinerary does something very much like this, to make std::min/std::max 
work without special-casing invalid values.

However the way it's done here will fail for negative max temperatures, as 
std::numeric_limits<double>::min() is not what one might expect (it's the 
smallest positive value for floating point types), you want 
std::numeric_limits<double>::lowest().

Regards,
Volker

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to