File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 11module Constants
22
3- import .. DEFAULT_QUANTITY_TYPE
43import .. Quantity
54import .. Units as U
6- import .. Units: _add_prefixes
5+ import .. Units: _add_prefixes, DEFAULT_UNIT_TYPE
76
87const _CONSTANT_SYMBOLS = Symbol[]
9- const _CONSTANT_VALUES = DEFAULT_QUANTITY_TYPE []
8+ const _CONSTANT_VALUES = DEFAULT_UNIT_TYPE []
109
1110macro register_constant (name, value)
1211 return esc (_register_constant (name, value))
2019function _register_constant (name:: Symbol , value)
2120 s = string (name)
2221 return quote
23- const $ name = $ value
22+ const $ name = convert (DEFAULT_UNIT_TYPE, $ value)
2423 push! (_CONSTANT_SYMBOLS, Symbol ($ s))
2524 push! (_CONSTANT_VALUES, $ name)
2625 end
8786)
8887
8988# Measured
90- @register_constant alpha DEFAULT_QUANTITY_TYPE (7.2973525693e-3 )
89+ @register_constant alpha DEFAULT_UNIT_TYPE (7.2973525693e-3 )
9190@register_constant u 1.66053906660e-27 * U. kg
9291@register_constant G 6.67430e-11 * U. m^ 3 / (U. kg * U. s^ 2 )
9392@register_constant mu_0 4 π * alpha * hbar / (e^ 2 * c)
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ Base.convert(::Type{LazyFloat64}, x::LazyFloat64) = x
1212Base. convert (:: Type{LazyFloat64} , x:: FixedRational ) = LazyFloat64 (convert (Float64, x))
1313Base. convert (:: Type{LazyFloat64} , x:: Number ) = LazyFloat64 (x)
1414Base. convert (:: Type{T} , x:: LazyFloat64 ) where {T<: Number } = convert (T, float (x))
15- Base. promote_rule (:: Type{LazyFloat64} , :: Type{T} ) where {T} = T
15+ Base. promote_rule (:: Type{LazyFloat64} , :: Type{T} ) where {T<: AbstractFloat } = T
16+ Base. promote_rule (:: Type{LazyFloat64} , :: Type{T} ) where {T} = promote_type (Float64, T)
1617
1718(:: Type{T} )(x:: LazyFloat64 ) where {T<: Number } = T (float (x))
1819
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import ..Quantity
77import .. LazyFloat64
88
99const DEFAULT_UNIT_BASE_TYPE = LazyFloat64
10- const DEFAULT_UNIT_TYPE = Quantity{DEFAULT_UNIT_TYPE ,DEFAULT_DIM_TYPE}
10+ const DEFAULT_UNIT_TYPE = Quantity{DEFAULT_UNIT_BASE_TYPE ,DEFAULT_DIM_TYPE}
1111
1212const _UNIT_SYMBOLS = Symbol[]
1313const _UNIT_VALUES = DEFAULT_UNIT_TYPE[]
You can’t perform that action at this time.
0 commit comments