split math lib into new file

This commit is contained in:
ValKmjolnir
2023-07-30 00:19:38 +08:00
parent d9d8044d64
commit 076bd1ef2e
9 changed files with 116 additions and 79 deletions
+13
View File
@@ -2,16 +2,29 @@
# 2023 by ValKmjolnir
# mostly used math functions and special constants, you know.
# constant e
var e = 2.7182818284590452354;
# constant pi
var pi = 3.14159265358979323846264338327950288;
# maybe useless, just tell you
# how to make inf and nan in IEEE754 double.
# carefully using these two constants,
# may cause critical error in calculation.
var inf = 1/0;
# nan can be created by (inf - inf) or (-inf + inf)
var nan = 0/0;
var abs = func(x) {
return x>0? x:-x;
}
# floor will get the integral number of input argument
# which is less than or equal to this argument.
# this is basic native function in old nasal,
# but we think it should have a copy in math module.
var floor = func(x) {
return __floor(x);
}