aboutsummaryrefslogtreecommitdiffstats
path: root/unit.c
diff options
context:
space:
mode:
Diffstat (limited to 'unit.c')
-rw-r--r--unit.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/unit.c b/unit.c
index de24dc3..d1e487d 100644
--- a/unit.c
+++ b/unit.c
@@ -18,6 +18,9 @@
/* Seconds per minute. */
#define SEC_PER_MIN 60.0
+/* Zero Celsius in Kelvin. */
+#define ZERO_C 273.15
+
AngularSpeed
rad_per_sec(double x) {
@@ -108,6 +111,50 @@ as_psi(Pressure x) {
}
+Temperature
+kelvin(double x) {
+ return x;
+}
+
+Temperature
+celsius(double x) {
+ return x + ZERO_C;
+}
+
+Temperature
+fahrenheit(double x) {
+ double c;
+
+ c = (x - 32.0) * 5.0 / 9.0;
+ return c + ZERO_C;
+}
+
+Temperature
+rankine(double x) {
+ return x * 5.0 / 9.0;
+}
+
+double
+as_kelvin(Temperature t) {
+ return t;
+}
+
+double
+as_celsius(Temperature t) {
+ return t - ZERO_C;
+}
+
+double
+as_fahrenheit(Temperature t) {
+ return as_celsius(t) * 9.0 / 5.0 + 32.0;
+}
+
+double
+as_rankine(Temperature t) {
+ return t * 9.0 / 5.0;
+}
+
+
Volume
cubic_centimetre(double x) {
return x * 1e-6;