The BSONElement contains a number of methods that coerce the field value into the range for a given type. Some of these methods have internal rules for converting NaN values, which apply to the Double and Decimal types specifically.
Some use cases may require different handling for NaN values rather than depend on the implicit conversion rules.
See BSONElement::safeNumberLong() for an example.
- is related to
SERVER-68359 Prevent TTLMonitor from processing index if expireAfterSeconds is NaN
SERVER-68477 Improve NaN-handling for expireAfterSeconds TTL index parameter