|
I gave the simplest solution that gives an integer result where possible and errors out otherwise.
you have to filter the values, specifically for NaN and any values larger than 0x1p+52 or less than -0x1p+52 (including +/-Inf) I would return verbatim.