MikeLankamp / fpm

C++ header-only fixed-point math library
https://mikelankamp.github.io/fpm
MIT License
672 stars 85 forks source link

fpm::isnormal has a different behaviour than std::isnormal #24

Closed davidgutierrezpalma closed 3 years ago

davidgutierrezpalma commented 3 years ago

The fpm::isnormal function returns true for every fixed point number, but the equivalent STL function returns false for std::isnormal(0.0).

https://www.cplusplus.com/reference/cmath/isnormal/

My proposed solution would be:

template <typename B, typename I, unsigned int F>
constexpr inline bool isnormal(fixed<B, I, F>) noexcept
{
    return x.raw_value() != B{0};
}
MikeLankamp commented 3 years ago

Hi @davidgutierrezpalma, you're right, I missed that part of the specification. Thanks for reporting it!