Skip to content

Commit c98958b

Browse files
committed
Fix ambiguity in div
1 parent 803a0be commit c98958b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/math.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
2+
div_base_type = type == AbstractGenericQuantity ? Number : base_type
23
@eval begin
34
function Base.:*(l::$type, r::$type)
45
l, r = promote_except_value(l, r)
@@ -20,7 +21,7 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
2021
function Base.:/(l::$type, r::$base_type)
2122
new_quantity(typeof(l), ustrip(l) / r, dimension(l))
2223
end
23-
function Base.div(x::$type, y::$base_type, r::RoundingMode=RoundToZero)
24+
function Base.div(x::$type, y::$div_base_type, r::RoundingMode=RoundToZero)
2425
new_quantity(typeof(x), div(ustrip(x), y, r), dimension(x))
2526
end
2627

@@ -30,7 +31,7 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
3031
function Base.:/(l::$base_type, r::$type)
3132
new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
3233
end
33-
function Base.div(x::$base_type, y::$type, r::RoundingMode=RoundToZero)
34+
function Base.div(x::$div_base_type, y::$type, r::RoundingMode=RoundToZero)
3435
new_quantity(typeof(y), div(x, ustrip(y), r), inv(dimension(y)))
3536
end
3637

0 commit comments

Comments
 (0)