git subrepo clone git@github.com:Rconybea/xo-unit.git xo-unit
subrepo: subdir: "xo-unit" merged: "f1e698bf" upstream: origin: "git@github.com:Rconybea/xo-unit.git" branch: "main" commit: "f1e698bf" git-subrepo: version: "0.4.9" origin: "???" commit: "???"
This commit is contained in:
parent
b135d1813b
commit
60f796b770
106 changed files with 11919 additions and 0 deletions
31
xo-unit/example/ex7/ex7.cpp
Normal file
31
xo-unit/example/ex7/ex7.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/** @file ex7.cpp **/
|
||||
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include "xo/unit/quantity_iostream.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
using namespace xo::qty;
|
||||
namespace u = xo::qty::u;
|
||||
namespace q = xo::qty::qty;
|
||||
using namespace std;
|
||||
|
||||
quantity qty1 = 7.55 * q::kilometer / q::minute / q::minute;
|
||||
quantity qty2 = q::nanograms(123);
|
||||
quantity qty3 = qty2 * qty1;
|
||||
|
||||
cerr << "qty1: " << qty1 << endl;
|
||||
cerr << "qty2: " << qty2 << endl;
|
||||
cerr << "qty3: " << qty3 << endl;
|
||||
|
||||
/* rescale to not-so-absurd units */
|
||||
|
||||
/* kg.m.s^-2 */
|
||||
quantity res = qty3.rescale_ext<u::kilogram * u::meter / (u::second * u::second)>();
|
||||
|
||||
/* 2.57958e-10kg.m.s^-2 */
|
||||
cerr << "res: " << res << endl;
|
||||
}
|
||||
|
||||
/** end ex7.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue