Skip to content

Commit

Permalink
Fix ambiguity in div
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Nov 21, 2023
1 parent 745cd9e commit 79bfd78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/math.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
div_base_type = type == AbstractGenericQuantity ? Number : base_type
@eval begin
function Base.:*(l::$type, r::$type)
l, r = promote_except_value(l, r)
Expand All @@ -20,7 +21,7 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
function Base.:/(l::$type, r::$base_type)
new_quantity(typeof(l), ustrip(l) / r, dimension(l))
end
function Base.div(x::$type, y::$base_type, r::RoundingMode=RoundToZero)
function Base.div(x::$type, y::$div_base_type, r::RoundingMode=RoundToZero)
new_quantity(typeof(x), div(ustrip(x), y, r), dimension(x))
end

Expand All @@ -30,7 +31,7 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
function Base.:/(l::$base_type, r::$type)
new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
end
function Base.div(x::$base_type, y::$type, r::RoundingMode=RoundToZero)
function Base.div(x::$div_base_type, y::$type, r::RoundingMode=RoundToZero)
new_quantity(typeof(y), div(x, ustrip(y), r), inv(dimension(y)))
end

Expand Down

0 comments on commit 79bfd78

Please sign in to comment.