I'm part of a team working on free and open source implementations of the OpenKODE specification for many platforms.
While working on the Utility functions we noticed the following macros, defined in kd.h, may be a source of problems with some C and C++ compilers:
#define KD_INFINITY (1.0F/0.0F)
#define KD_NAN (0.0F/0.0F)
#define KD_HUGE_VALF ( 1.0F/0.0F)
Although they define perfectly valid floating-point arithmetic according to the IEC 559 / IEEE 754 standard, some standards specify that an explicit division-by-zero is the product of an ill-formed program. This usually
in either undefined behaviour or a compile time error. The latter occurs in the MS C Compiler but we think it's safe to assume that this may happen in other compilers.
Our current solution involves using platform dependent constants selected at compile time. However, we intend to fully comply with the spec.
What is the best way to deal with this issue?