mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-23 11:28:45 +08:00
✨ split math lib into new file
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user