Basically:
julia> using Unitful
julia> x = 1.0u"nm"
1.0 nm
julia> zero(typeof(x))
0.0 nm
julia> one(typeof(x))
1.0
julia>
Why one(typeof(x))
is not 1.0 nm
? And which is the alternative to using one
for unit propagation if one has to do something like
julia> f(x::T) = x + one(T)/2
f (generic function with 1 method)
julia> f(1.0u"nm")
ERROR: DimensionError: 1.0 nm and 0.5 are not dimensionally compatible.
Stacktrace:
edit:
T(0.5)
is the alternative.
If anyone has further comments, please let me know.