Multiplication UnitValue * Number

This commit is contained in:
cdricms
2025-09-13 22:55:24 +02:00
parent d8809f2bdd
commit 0356d68cf2

View File

@@ -383,6 +383,23 @@ public struct UnitValue<ValueType: ConvertibleToDouble>:
(lhs.value * rhs.value)[lhs.unit] (lhs.value * rhs.value)[lhs.unit]
} }
/// The result will have the `unit` of the left hand side value.
public static func * <L: ConvertibleToDouble, R: ConvertibleToDouble>(
lhs: UnitValue<L>, rhs: R
)
-> UnitValue<Double>
{
(lhs.value * rhs.doubleValue)[lhs.unit]
}
public static func * <L: ConvertibleToDouble, R: ConvertibleToDouble>(
lhs: L, rhs: UnitValue<R>
)
-> UnitValue<Double>
{
(lhs.doubleValue * rhs.value)[rhs.unit]
}
/// The result will have the `unit` of the left hand side value. /// The result will have the `unit` of the left hand side value.
public static func / <L: ConvertibleToDouble, R: ConvertibleToDouble>( public static func / <L: ConvertibleToDouble, R: ConvertibleToDouble>(
lhs: UnitValue<L>, rhs: UnitValue<R> lhs: UnitValue<L>, rhs: UnitValue<R>