Bugzilla #43940: Fix handling of NaN, {+,-}Infinity, and other edge cases. Submitted by Julien Aymé.