2 ms·
The Boost.Units library for C++ does this: http://www.boost.org/doc/libs/1_53_0/doc/html/boost_units/Quick_Start.html http://www.boost.org/doc/libs/1_53_0/doc/h
by scott_s 14y ago
The Boost.Units library for C++ does this: http://www.boost.org/doc/libs/1_53_0/doc/html/boost_units/Quick_Start.html http://www.boost.org/doc/libs/1_53_0/doc/html/boost_units/Qu...
Some examples from the documentation:
quantity<length> L = 2.0*meters;
quantity<energy> E = kilograms*pow<2>(L/seconds);
quantity<plane_angle> theta = 0.375*radians;
quantity<dimensionless> sin_theta = sin(theta);
quantity<plane_angle> thetap = asin(sin_theta);
I figured Haskell's type system could also do this sort of thing, and it can. I found Dimensional: https://code.google.com/p/dimensional/ https://code.google.com/p/dimensional/, but I'm not sure if it's in standard use in the Haskell community. Examples: https://code.google.com/p/dimensional/wiki/IspExample https://code.google.com/p/dimensional/wiki/IspExample