mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +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:
committed by
Thomas Krijnen
parent
f9f756ae79
commit
4e54f67cc0
@@ -199,8 +199,8 @@ class Unit(bonsai.core.tool.Unit):
|
|||||||
if inches is None:
|
if inches is None:
|
||||||
inches = 0
|
inches = 0
|
||||||
|
|
||||||
# If feet is negative, inches should also be negative (subtractive)
|
# If feet is negative (including -0), inches should also be negative (subtractive)
|
||||||
if feet < 0:
|
if math.copysign(1, feet) < 0:
|
||||||
inches = -inches
|
inches = -inches
|
||||||
|
|
||||||
# Convert to meters
|
# Convert to meters
|
||||||
|
|||||||
Reference in New Issue
Block a user