From 4724959ee63e5e050fb9d7f30de9a62ee2760f1b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 4 Jul 2023 18:11:45 +0200 Subject: [PATCH] GDALBufferHasOnlyNoData() / GTiff SPARSE_OK=YES: recognize negative floating point 0 as 0 (fixes #8025) --- gcore/rasterio.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcore/rasterio.cpp b/gcore/rasterio.cpp index 928d76daf949..0943ccf950a9 100644 --- a/gcore/rasterio.cpp +++ b/gcore/rasterio.cpp @@ -5110,7 +5110,10 @@ bool GDALBufferHasOnlyNoData(const void *pBuffer, double dfNoDataValue, #else typedef std::uint32_t WordType; #endif - if (dfNoDataValue == 0.0 && nWidth == nLineStride) + if (dfNoDataValue == 0.0 && nWidth == nLineStride && + // Do not use this optimized code path for floating point numbers, + // as it can't detect negative zero. + nSampleFormat != GSF_FLOATING_POINT) { const GByte *pabyBuffer = static_cast(pBuffer); const size_t nSize =