ggggggggg / Physical.jl

Units, physical constants, error propagation.
MIT License
7 stars 5 forks source link

sqrt(Q) doesn't yield correct units #3

Closed tomasaschan closed 10 years ago

tomasaschan commented 10 years ago

If I have 4 square meters, and take the square, I expect to get 2 meters - but now I get 2 square meters. Is this a conscious decision, or a bug?

s = 4 * Meter^2
@show s
# s => 4 m^2
@show sqrt(s)
# sqrt(s) => 2 m^2

This behavior is unpractical for using Physical in more complex situations. For example, it quickly breaks down if one wants to calculate some velocity from a kinetic energy, which is a very common operation in statistical mechanics; v = sqrt(2E/m), if E is in energy units and m is in mass units, will now yield v in meters squared per second squared, m^2/s^2, instead of in meters per second...

tomasaschan commented 10 years ago

As a workaround, I can use (Q)^(1/2). But I shouldn't have to =)

ggggggggg commented 10 years ago

Definitely a bug, thanks for the fix.