Skip to content

Commit

Permalink
update rounding code
Browse files Browse the repository at this point in the history
  • Loading branch information
BeastyBlacksmith authored and Simon Christ committed Jun 27, 2019
1 parent b24d9fb commit 4a39374
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ for f in (:floor, :ceil, :trunc, :round)
@eval ($f)(::Type{T}, x::DimensionlessQuantity; kwargs...) where {T <: Integer} = ($f)(T, uconvert(NoUnits, x); kwargs...)
@eval ($f)(::Type{T}, x::Quantity; kwargs...) where {T <: Quantity} = T(($f)(uconvert(unit(T), x).val; kwargs...))
end
round(x::DimensionlessQuantity, r::RoundingMode=RoundNearest; kwargs...) = round(uconvert(NoUnits, x), r; kwargs...)
round(::Type{T}, x::AbstractQuantity) where {T <: Integer} = _dimerr(round)
round(::Type{T}, x::DimensionlessQuantity) where {T <: Integer} = round(T, uconvert(NoUnits, x))

zero(x::AbstractQuantity) = Quantity(zero(x.val), unit(x))
zero(x::AffineQuantity) = Quantity(zero(x.val), absoluteunit(x))
Expand Down

0 comments on commit 4a39374

Please sign in to comment.