Skip to main content

normalize_float_zero

Function normalize_float_zero 

Source
pub fn normalize_float_zero(array: &ArrayRef) -> ArrayRef
Expand description

Replace -0.0 with +0.0 in any Float16, Float32, or Float64 array. For non-float arrays returns the input unchanged. NaN payloads are preserved.

Arrow’s comparison kernels (arrow::compute::kernels::cmp::eq etc.) and row-encoding (arrow::row::RowConverter) use IEEE 754 totalOrder semantics, which treats -0.0 and +0.0 as distinct. SQL semantics (PostgreSQL / IEEE 754 equality) require them to compare equal, so callers normalize before invoking those kernels.

The common case - no -0.0 present - is allocation-free: a single read-only scan of the underlying buffer (auto-vectorizable to an OR-reduction) decides whether to fall through to the rewriting path. Only arrays that actually contain -0.0 pay for a new buffer.