From 92b3aaf86d9a71441b47d354a5a550f5696d836b Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 14 Apr 2026 06:35:35 -0500 Subject: [PATCH] BUG: Fix float-precision division in BresenhamLine::BuildLine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add explicit static_cast() on both operands of the division computing euclideanLineLen. Because LType = Vector, the expression `IdentifierType / float` previously evaluated in float precision; the double result was only a widened float quotient. Assisted-by: Greptile — identified float-precision division in BuildLine --- Modules/Core/Common/include/itkBresenhamLine.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Core/Common/include/itkBresenhamLine.hxx b/Modules/Core/Common/include/itkBresenhamLine.hxx index d7eac6d53b7..d86d2ef33db 100644 --- a/Modules/Core/Common/include/itkBresenhamLine.hxx +++ b/Modules/Core/Common/include/itkBresenhamLine.hxx @@ -41,7 +41,8 @@ BresenhamLine::BuildLine(LType Direction, IdentifierType length) -> // compute actual line length because the shorter distance // the larger deviation due to rounding to integers const IdentifierType mainDirectionLen = length - 1; - const double euclideanLineLen = mainDirectionLen / itk::Math::Absolute(Direction[maxDistanceDimension]); + const double euclideanLineLen = + static_cast(mainDirectionLen) / static_cast(itk::Math::Absolute(Direction[maxDistanceDimension])); // we are going to start at 0 constexpr IndexType StartIndex{ 0 };