diff --git a/coloraide/algebra.py b/coloraide/algebra.py index 9d1c8935..859ace92 100644 --- a/coloraide/algebra.py +++ b/coloraide/algebra.py @@ -71,6 +71,14 @@ ################################ # General math ################################ +def sign(x: float) -> float: + """Return the sign of a given value.""" + + if x and x == x: + return x / abs(x) + return x + + def order(x: float) -> int: """Get the order of magnitude of a number.""" diff --git a/coloraide/temperature/ohno_2013.py b/coloraide/temperature/ohno_2013.py index 7b26dac2..91f2700a 100644 --- a/coloraide/temperature/ohno_2013.py +++ b/coloraide/temperature/ohno_2013.py @@ -224,7 +224,7 @@ def to_cct( x = (dp ** 2 - dn ** 2 + l ** 2) / (2 * l) t = tp + (tn - tp) * (x / l) vtx = vp + (vn - vp) * (x / l) - sign = math.copysign(1, v - vtx) + sign = alg.sign(v - vtx) duv = (dp ** 2 - x ** 2) ** (1 / 2) * sign # Parabolic solution