To be fair, bitwise operations only really come in trivial or cryptic.
[...]
So I did what any reasonable person would do in the circumstances: Copy-pasted the lot into an isNumberwang() function and backed away slowly.
That's exactly what I did with my 20-year old C code.
I Copy-pasted it into my Visual Studio C# project, and fixed up the types and syntax as required.
Well, not quite copy-paste.
I had archive on 5-1/4 floppy, and papyrus hard-copy.
Guess what was the most useful.
After re-reading it a few times, it did come back to me exactly what I was doing, but I CBA documenting it now.
"It was hard to write, so it should be hard to understand".
Even for the original author!
What the code does is to use AND masks to seperate out the 3 components of the original xs-64 format
( which has been loaded as a dumb 32-bit unsigned Int to allow me to bit-twiddle them. )
The sign bit, the exponent, and the mantissa.
It then bit-shifts these 3 into a position I need to work with them.
I then do magic bit-wise manipulations on these components, to perform the actual translation between formats.
I then shift the results into their final positions, do an AND to mask out any spurious bits, and then OR the components back together into a final result.
Then I use an arcane thing called a Union which allows me to tell C / C# to put on different glasses and view these 4 bytes which were previously a UInt type as a Float type.
It's the most wonderfully arcane bit of obfuscated C.