I would like to ask a question that follows this one which is pretty well answered by the define check if the compiler uses the standard. However this woks for C only. Is there a way to do the same in C++?
I do not wish to covert floating point types to text or use some pretty complex conversion functions. I just need the compiler check. If you know a list of such compatible compilers please post the link. I could not find it.
Actually you have an easier way to achieve this in C++. From the C++ standard
18.2.1.1
the classnumeric_limits
exists withinstd
. In order to access said static member you simply do this:Or:
Which should return
true
if IEEE 754 is in use, false otherwise.As an alternative method, the second part of Adam's answer should do it also for C++.
Although this post is a bit old (10 years), you could still try this. It also works in C: