aboutsummaryrefslogtreecommitdiff
path: root/bc_funcs
diff options
context:
space:
mode:
authorMango0x45 <thomasvoss@live.com>2021-01-18 21:49:09 +0000
committerMango0x45 <thomasvoss@live.com>2021-01-18 21:49:09 +0000
commit91b4d2e34e27f4d3c5c7efc5490e8ab3540be138 (patch)
treedb01197df1bdb66a856b905f8451c2d8dd7d2ef2 /bc_funcs
parent1c4ab84de4804bb2824bd6cf071821a8e1892e24 (diff)
downloadsteve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.tar
steve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.tar.gz
steve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.tar.bz2
steve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.tar.lz
steve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.tar.xz
steve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.tar.zst
steve-bot-91b4d2e34e27f4d3c5c7efc5490e8ab3540be138.zip
Merge BC files into one
Diffstat (limited to 'bc_funcs')
-rw-r--r--bc_funcs/lib.bc (renamed from bc_funcs/trig.bc)31
-rw-r--r--bc_funcs/std.bc30
2 files changed, 31 insertions, 30 deletions
diff --git a/bc_funcs/trig.bc b/bc_funcs/lib.bc
index 9a4fcb3..d413763 100644
--- a/bc_funcs/trig.bc
+++ b/bc_funcs/lib.bc
@@ -96,3 +96,34 @@ define atan(x) {
ibase = b
return ((m * a + r) / n)
}
+
+define abs(x) {
+ if (x < 0)
+ x *= -1
+ return x
+}
+
+define fact(x) {
+ auto r, s
+
+ if (x < 0) {
+ print "Error: Negative factorial\n"
+ return 0
+ }
+
+ /* x % 1 requires scale set to 0 */
+ s = scale
+ scale = 0
+ if (x % 1 != 0) {
+ print "Error: Non-integer factorial\n"
+ scale = s
+ return 0
+ }
+
+ r = 1
+ for (i = 2; i <= x; i++)
+ r *= i
+
+ scale = s
+ return r
+}
diff --git a/bc_funcs/std.bc b/bc_funcs/std.bc
deleted file mode 100644
index e90231e..0000000
--- a/bc_funcs/std.bc
+++ /dev/null
@@ -1,30 +0,0 @@
-define abs(x) {
- if (x < 0)
- x *= -1
- return x
-}
-
-define fact(x) {
- auto r, s
-
- if (x < 0) {
- print "Error: Negative factorial\n"
- return 0
- }
-
- /* x % 1 requires scale set to 0 */
- s = scale
- scale = 0
- if (x % 1 != 0) {
- print "Error: Non-integer factorial\n"
- scale = s
- return 0
- }
-
- r = 1
- for (i = 2; i <= x; i++)
- r *= i
-
- scale = s
- return r
-}