A Julia library for unit types validated unit conversions.
Load the library via require("SI.jl")
then display the available types and explicit conversions with showSI()
.
Note:
Implicit types and conversions are available as long as each unit is defined within SI.jl
Example:
The type m/s
is not defined, but both m
(meters) and s
(seconds) are defined.
distance = SI(90.2, :km) # kilometers
time = SI(4.2, :s) # seconds
velocity = distance/time
SI(21.476190476190474,:km/s,"kilometers per second",:velocity)
velocity >> symbol("m/s") # use symbol function for units containing '/'
SI(21476.190079180236,:m/s,"meters per second",:velocity)
To add your own unit conversions to the unit_conversions.jl
file.
- Use the macro
@conversion
to include the user defined function withinshowSI()
. - Use the style of
this_to_that(this)
function names.