Skip to content

unchained to on Measurement[SomeUnit] returns unchanged value and accepts unit of any quantity #18

@arkanoid87

Description

@arkanoid87
from std/sugar import dump
import unchained
import measuremancer

defUnit(Yard•Minute⁻¹)
defUnit(parsec•lbs)

proc main() =
  let x = 1.m
  let y = 2.s
  let xy = x / y
  let mx = x ± 0.1.m
  let my = y ± 0.1.s
  let mxy = mx / my
  dump x
  dump y
  dump xy
  dump x.to(yd)
  dump y.to(Minute)
  dump xy.to(Yard•Minute⁻¹)
  dump mx
  dump my
  dump mxy
  dump mx.to(yd)
  dump my.to(Minute)
  dump mxy.to(Yard•Minute⁻¹)
  dump mxy.to(Liter)
  dump mxy.to(slug)
  dump mxy.to(parsec•lbs)

when isMainModule:
  main()
x = 1 m
y = 2 s
xy = 0.5 m•s⁻¹
x.to(yd) = 1.09361 yd
y.to(Minute) = 0.0333333 min
xy.to(Yard•Minute⁻¹) = 32.8084 yd•min⁻¹
mx = 1.00 ± 0.100 Meter
my = 2.00 ± 0.100 Second
mxy = 0.500 ± 0.0559 Meter•Second⁻¹
mx.to(yd) = 1.00 ± 0.100 Yard
my.to(Minute) = 2.00 ± 0.100 Minute
mxy.to(Yard•Minute⁻¹) = 0.500 ± 0.0559 Yard•Minute⁻¹
mxy.to(Liter) = 0.500 ± 0.0559 Liter
mxy.to(slug) = 0.500 ± 0.0559 Slug
mxy.to(parsec•lbs) = 0.500 ± 0.0559 Parsec•Pound

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions