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 1
1
module Constants
2
2
3
- import .. DEFAULT_QUANTITY_TYPE
4
3
import .. Quantity
5
4
import .. Units as U
6
- import .. Units: _add_prefixes
5
+ import .. Units: _add_prefixes, DEFAULT_UNIT_TYPE
7
6
8
7
const _CONSTANT_SYMBOLS = Symbol[]
9
- const _CONSTANT_VALUES = DEFAULT_QUANTITY_TYPE []
8
+ const _CONSTANT_VALUES = DEFAULT_UNIT_TYPE []
10
9
11
10
macro register_constant (name, value)
12
11
return esc (_register_constant (name, value))
20
19
function _register_constant (name:: Symbol , value)
21
20
s = string (name)
22
21
return quote
23
- const $ name = $ value
22
+ const $ name = convert (DEFAULT_UNIT_TYPE, $ value)
24
23
push! (_CONSTANT_SYMBOLS, Symbol ($ s))
25
24
push! (_CONSTANT_VALUES, $ name)
26
25
end
87
86
)
88
87
89
88
# Measured
90
- @register_constant alpha DEFAULT_QUANTITY_TYPE (7.2973525693e-3 )
89
+ @register_constant alpha DEFAULT_UNIT_TYPE (7.2973525693e-3 )
91
90
@register_constant u 1.66053906660e-27 * U. kg
92
91
@register_constant G 6.67430e-11 * U. m^ 3 / (U. kg * U. s^ 2 )
93
92
@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
12
12
Base. convert (:: Type{LazyFloat64} , x:: FixedRational ) = LazyFloat64 (convert (Float64, x))
13
13
Base. convert (:: Type{LazyFloat64} , x:: Number ) = LazyFloat64 (x)
14
14
Base. 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)
16
17
17
18
(:: Type{T} )(x:: LazyFloat64 ) where {T<: Number } = T (float (x))
18
19
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import ..Quantity
7
7
import .. LazyFloat64
8
8
9
9
const 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}
11
11
12
12
const _UNIT_SYMBOLS = Symbol[]
13
13
const _UNIT_VALUES = DEFAULT_UNIT_TYPE[]
You can’t perform that action at this time.
0 commit comments