FdLibm
Port of the "Freely Distributable Math Library", version 5.3, from C to Java. Then port from Java to Kotlin Multiplatform for lucene-kmp.
The C version of fdlibm relied on the idiom of pointer aliasing a 64-bit double floating-point value as a two-element array of 32-bit integers and reading and writing the two halves of the double independently. This coding pattern was problematic to C optimizers and not directly expressible in Java. Therefore, rather than a memory level overlay, if portions of a double need to be operated on as integer values, the standard library methods for bitwise floating-point to integer conversion, Double.longBitsToDouble and Double.doubleToRawLongBits, are directly or indirectly used.
The C version of fdlibm also took some pains to signal the correct IEEE 754 exceptional conditions divide by zero, invalid, overflow and underflow. For example, overflow would be signaled by {@code huge * huge} where {@code huge} was a large constant that would overflow when squared. Since IEEE floating-point exceptional handling is not supported natively in the JVM, such coding patterns have been omitted from this port. For example, rather than {@code return huge * huge}, this port will use {@code return INFINITY}.
Various comparison and arithmetic operations in fdlibm could be done either based on the integer view of a value or directly on the floating-point representation. Which idiom is faster may depend on platform specific factors. However, for code clarity if no other reason, this port will favor expressing the semantics of those operations in terms of floating-point operations when convenient to do so.