From 7f734e912b26e6dc35ac0a26e343f48b38740fd5 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Wed, 14 Jan 2026 17:04:27 -0500 Subject: [PATCH] fix: Fixes rectangular duct rounding. --- Sources/ManualDClient/Live.swift | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/Sources/ManualDClient/Live.swift b/Sources/ManualDClient/Live.swift index 3b7768f..2b37c81 100644 --- a/Sources/ManualDClient/Live.swift +++ b/Sources/ManualDClient/Live.swift @@ -38,23 +38,7 @@ extension ManualDClient: DependencyKey { }, equivalentRectangularDuct: { request in let width = (Double.pi * (pow(Double(request.roundSize) / 2.0, 2.0))) / Double(request.height) - // Round the width up or fail (really should never fail since we know the input is a number). - guard let widthStr = numberFormatter.string(for: width), - let widthInt = Int(widthStr) - else { - throw ManualDError( - message: "Failed to convert to to rectangular duct size, width: \(width)" - ) - } - return .init(height: request.height, width: widthInt) + return .init(height: request.height, width: Int(width.rounded(.toNearestOrEven))) } ) } - -private let numberFormatter: NumberFormatter = { - let formatter = NumberFormatter() - formatter.maximumFractionDigits = 0 - formatter.minimumFractionDigits = 0 - formatter.roundingMode = .ceiling - return formatter -}()