From Jason Turner
Watch on YouTube

Summary

In this episode, Jason explores C++11's std::fmin function, which provides special handling for floating-point comparisons involving NaN (Not a Number) values. Unlike std::min, which returns NaN when it appears as a parameter, std::fmin treats NaN as a placeholder value and always returns the non-NaN value regardless of parameter order. Jason demonstrates this behavior and notes that std::fmin returns by value rather than by reference. He then extends his variadic min implementation from the previous episode to create a variadic version of fmin, allowing for convenient comparison of multiple floating-point values with proper NaN handling.

Resources

Tags