fn double_to_json(f: f64) -> Result<Value, RError>
Convert an f64 to a JSON number, handling special values.