aboutsummaryrefslogtreecommitdiff
path: root/include/base
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-12-05 16:16:21 -0800
committerNicholas Noll <nbnoll@eml.cc>2021-12-05 16:16:21 -0800
commit07e77936d535e58b0aeb4f2a11400c1050556739 (patch)
treefb50fad6436ecbc159505bee73a92cd289b99a07 /include/base
parentb48327d357e0818d1a6ae2a064cfa7d1567e1242 (diff)
Feat: added math library
Used Plan9's libc as starting point. This cleans up dangling references due to loss of libc.
Diffstat (limited to 'include/base')
-rw-r--r--include/base/math.h39
-rw-r--r--include/base/string.h8
2 files changed, 46 insertions, 1 deletions
diff --git a/include/base/math.h b/include/base/math.h
new file mode 100644
index 0000000..69d344e
--- /dev/null
+++ b/include/base/math.h
@@ -0,0 +1,39 @@
+#pragma once
+
+double math·NaN(void);
+double math·Inf(int);
+int math·isNaN(double);
+int math·isInf(double, int);
+ulong math·umuldiv(ulong, ulong, ulong);
+long math·muldiv(long, long, long);
+
+double math·pow(double, double);
+double math·atan2(double, double);
+double math·fabs(double);
+double math·atan(double);
+int math·abs(int);
+long math·labs(long);
+double math·ldexp(double, int);
+double math·log(double);
+double math·log10(double);
+double math·exp(double);
+double math·floor(double);
+double math·ceil(double);
+double math·sin(double);
+double math·cos(double);
+double math·tan(double);
+double math·asin(double);
+double math·acos(double);
+double math·sinh(double);
+double math·cosh(double);
+double math·tanh(double);
+double math·sqrt(double);
+double math·fmod(double, double);
+double math·modf(double, double*);
+double math·frexp(double, int*);
+
+double math·copysign(double, double);
+
+#define math·HUGE 3.4028234e38
+#define math·PIO2 1.570796326794896619231e0
+#define math·PI (math·PIO2+math·PIO2)
diff --git a/include/base/string.h b/include/base/string.h
index 238ebf9..a59c553 100644
--- a/include/base/string.h
+++ b/include/base/string.h
@@ -29,9 +29,15 @@ int str·compare(char *, char *);
int str·ncompare(char *, intptr len, char *);
int str·ecompare(char *, char *end, char *);
-int str·atoi(char *s);
+/* old school interfaces (no error checking) */
+long str·atoi(char *s);
+double str·atof(char *s);
char *str·itoa(char *s, int x);
+/* nicer */
+vlong str·asint(char *s, char **end);
+double str·asfloat(char *s, char **end);
+
/* augmented string functions */
string string·makecap(char *s, vlong len, vlong cap);
string string·makelen(char *s, vlong len);