Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Unitful.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Unitful

import Base: ==, <, <=, +, -, *, /, .+, .-, .*, ./, .\, //, ^, .^
import Base: show, convert
import Base: abs, abs2, float, inv, sqrt
import Base: abs, abs2, float, fma, inv, sqrt
import Base: min, max, floor, ceil, log, log10, real, imag, conj

import Base: mod, rem, div, fld, cld, trunc, round, sign, signbit
Expand Down Expand Up @@ -588,6 +588,12 @@ end
^{T,D,U}(x::Quantity{T,D,U}, y::Real) = Quantity((x.val)^y, U()^y)

# Other mathematical functions
@inline function fma{T,D,U}(x::Number, y::Quantity{T,D,U}, z::Quantity{T,D,U})
c = fma(x, y.val, z.val)
Quantity(c, U())
end
fma(x::Number, y::Quantity, z::Quantity) = fma(x, promote(y, z)...)

"""
```
sqrt(x::Quantity)
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ end
@test V*(3+4im) == (3V+4V*im)
@test (3.0+4.0im)*V == (3+4im)*V
@test im*V == Complex(0,1)*V
@test fma(2.0, 3.0m, 1.0m) == 7.0m
@test fma(2.0, 3.0m, 35mm) == 6.035m
end

@testset "> Addition and subtraction" begin
Expand Down