Skip to content

Commit a7e81bc

Browse files
committed
docs(datafusion): clarify IEEE-754 rationale in arithmetic comments
Address review feedback: explain the multiply/divide rejection using explicit IEEE-754 facts (inf is not NaN but inf * 0 is NaN; 0 is not NaN but 0 / 0 is NaN) instead of the previous terse wording.
1 parent 8814873 commit a7e81bc

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,10 @@ fn resolve_nan_preserving_binary(binary: &BinaryExpr) -> Option<Reference> {
296296
}
297297

298298
// `x * c` and `c * x` are NaN iff `x` is NaN, but only when `c` is
299-
// non-zero: `±inf * 0` is NaN even though `±inf` is not. The column may
300-
// be on either side.
299+
// non-zero. Per IEEE-754:
300+
// - inf is not NaN
301+
// - inf * 0 is NaN
302+
// so multiplying by zero is rejected. The column may be on either side.
301303
Operator::Multiply => {
302304
if matches!(finite_literal(right), Some(c) if c != 0.0) {
303305
resolve_nan_preserving_reference(left)
@@ -309,8 +311,11 @@ fn resolve_nan_preserving_binary(binary: &BinaryExpr) -> Option<Reference> {
309311
}
310312

311313
// `x / c` is NaN iff `x` is NaN, for a finite non-zero literal `c`.
312-
// `c / x` is rejected because it is not NaN-preserving (e.g. `0 / 0` is
313-
// NaN while `0` is not), so the column must be the dividend (left side).
314+
// `c / x` is rejected and the column must be the dividend (left side).
315+
// Per IEEE-754:
316+
// - 0 is not NaN
317+
// - 0 / 0 is NaN
318+
// so `c / x` is not NaN-preserving.
314319
Operator::Divide => {
315320
if matches!(finite_literal(right), Some(c) if c != 0.0) {
316321
resolve_nan_preserving_reference(left)

0 commit comments

Comments
 (0)