MikeLankamp / fpm

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

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

Closed davidgutierrezpalma closed 2 years ago

davidgutierrezpalma commented 2 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 2 years ago

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