aboutsummaryrefslogtreecommitdiffstats
path: root/unit.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-02-28 15:23:05 -0500
committerSam Anthony <sam@samanthony.xyz>2025-02-28 15:23:05 -0500
commitd4976912beceb70a110050f212d5a1f17f974f17 (patch)
tree4483a9990b26b05018d8bc63b468eb46e333967f /unit.c
parent24f0677b76ba5be7114031f2d6d6746dcb64ce55 (diff)
downloadvolute-d4976912beceb70a110050f212d5a1f17f974f17.zip
volume unit conversion functions
Diffstat (limited to 'unit.c')
-rw-r--r--unit.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/unit.c b/unit.c
index 702f56c..fde768f 100644
--- a/unit.c
+++ b/unit.c
@@ -45,11 +45,42 @@ double as_bar(Pressure x);
double as_psi(Pressure x);
-Volume cubic_centimetre(double x);
-Volume litre(double x);
-Volume cubic_metre(double x);
-Volume cubic_inch(double x);
-double as_cubic_centimetre(Volume x);
-double as_litre(Volume x);
-double as_cubic_metre(double x);
-double as_cubic_inch(double x);
+Volume
+cubic_centimetre(double x) {
+ return x * 1e-6;
+}
+
+Volume
+litre(double x) {
+ return x * 1e-3;
+}
+
+Volume
+cubic_metre(double x) {
+ return x;
+}
+
+Volume
+cubic_inch(double x) {
+ return x * 1.6387064e-5;
+}
+
+double
+as_cubic_centimetre(Volume x) {
+ return x * 1e6;
+}
+
+double
+as_litre(Volume x) {
+ return x * 1e3;
+}
+
+double
+as_cubic_metre(double x) {
+ return x;
+}
+
+double
+as_cubic_inch(double x) {
+ return x / 1.6387064e-5;
+}