wgtmac commented on code in PR #861:
URL: https://github.com/apache/iceberg-cpp/pull/861#discussion_r3688902904


##########
src/iceberg/expression/literal.cc:
##########
@@ -444,7 +444,9 @@ std::strong_ordering CompareFloat(T lhs, T rhs) {
   // and -NAN < NAN.
   bool lhs_is_negative = std::signbit(lhs);
   bool rhs_is_negative = std::signbit(rhs);
-  return lhs_is_negative <=> rhs_is_negative;
+  // A negative sign bit sorts below a positive one (-NaN < +NaN), so a
+  // negative operand must compare as less.
+  return rhs_is_negative <=> lhs_is_negative;

Review Comment:
   Can we directly use function proposed by 
https://parquet.apache.org/blog/2026/05/29/taming-floating-point-statistics-in-apache-parquet-ieee-754-total-order-and-nan-counts/
 for IEEE754 total order?
   
   ```
   pub fn totalOrder(x: f64, y: f64) -> bool {
       let mut x_int = x.to_bits() as i64;
       let mut y_int = y.to_bits() as i64;
       x_int ^= (((x_int >> 63) as u64) >> 1) as i64;
       y_int ^= (((y_int >> 63) as u64) >> 1) as i64;
       return x_int <= y_int;
   }
   ```
   
   It is a piece of Rust code for f64 but would be easy to be adapted to f32.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to