-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_example.cpp
34 lines (28 loc) · 969 Bytes
/
main_example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//============================================================================
// Name : main.cpp
// Author : Soki Sakurai
// Version :
// Copyright : free for all
// Description : UnitAndValue sample program
//============================================================================
#include "Value.hpp"
#include "ValueMath.hpp"
#include "Rational.hpp"
#include <iostream>
using namespace std;
using namespace hongo;
int main() {
//A minimum kinetic energy of De Lorean when traveling through time.
Value mass(1244,"kg");
Value speed(88,"mi/h");
Value Ek = 0.5*mass*speed*speed;
cout << Ek.getValueIn("kJ") << " kJ" << endl;
//An initial speed when Doraemon jumps at the sight of a mouse.
Value g(9.8,"m/s^2");
Value h(129.3,"cm");
Rational index(1,2); //index=1/2
Value v = ValueMath::vpow(2*g*h, index);
// Value v = ValueMath::vsqrt(2*g*h); //equivalent expression
cout << v.getValueIn("m/s") << " m/s" << endl;
return 0;
}