mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix negative zero in imperial feet-inches parser
When the user enters `-0' - 10"`, Python parses feet as -0.0. The check `feet < 0` is False for negative zero, so the sign was silently dropped. Use math.copysign to detect it correctly. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -199,8 +199,8 @@ class Unit(bonsai.core.tool.Unit):
|
||||
if inches is None:
|
||||
inches = 0
|
||||
|
||||
# If feet is negative, inches should also be negative (subtractive)
|
||||
if feet < 0:
|
||||
# If feet is negative (including -0), inches should also be negative (subtractive)
|
||||
if math.copysign(1, feet) < 0:
|
||||
inches = -inches
|
||||
|
||||
# Convert to meters
|
||||
|
||||
Reference in New Issue
Block a user