How to make a constexpr that equals -0.0
Any way for me to set a constexpr to negative 0?
A legacy library uses negative 0 to indicate the calculation failed so I want to create a constexpr float fNEGZERO = -0.0.
Normally I would create this using a union between a uint32 and a float and set the uint32 bits to 0x8000'0000. But constexpr doesn't allow having a union access the non-active member. In theory the compiler does the same thing for NaN, +Inf, etc. but looking at numeric_limits it seems like they rely on built in 开发者_如何学编程compiler values.
精彩评论