You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
runnableExamples:
typeLength="m".makeUnit # can be also defined from other powers of other unitsTime="s".makeUnit
Mass="kg".makeUnit
var a =Time(1.2)
var b =Length(3.2)
var c =Mass(5.4)
assert$a.float=="1.2"assert$a =="1.2's"assert$(a*a*a) =="1.728's³"assert$(a*a*a*b*b) =="17.69472's³*m²"assert$b =="3.2'm"assert$(a*b) =="3.84's*m"assert$(a/b*c*c) =="10.935's*1/m*kg²"assert$(Time(1.2)/Length(3.2)*Mass(5.4)*Mass(5.4)) =="10.935's*1/m*kg²"
implementation
I implemented this in a private branch.
note
it's a completely different approach from https://github.com/def-/nim-units/blob/master/units.nim, which is a hacky/not general/more complex solution that hardcodes fixed units (and fixed powers of such units, eg you can't get s^3 unless you hardcode it)
The text was updated successfully, but these errors were encountered:
proposal
std/units
example
implementation
I implemented this in a private branch.
note
it's a completely different approach from https://github.com/def-/nim-units/blob/master/units.nim, which is a hacky/not general/more complex solution that hardcodes fixed units (and fixed powers of such units, eg you can't get s^3 unless you hardcode it)
The text was updated successfully, but these errors were encountered: