Added more math consts (#404)

This commit is contained in:
Wannes 2023-01-30 09:12:28 +01:00 committed by GitHub
parent 3f4245d962
commit ecc3d9181e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 11 deletions

View file

@ -18,6 +18,28 @@ math := import("math")
- `ln10`
- `ln10E`
Mathematical constants.
- `maxFloat32`
- `smallestNonzeroFloat32`
- `maxFloat64`
- `smallestNonzeroFloat64`
Floating-point limit values. Max is the largest finite value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type.
- `maxInt`
- `minInt`
- `maxInt8`
- `minInt8`
- `maxInt16`
- `minInt16`
- `maxInt32`
- `minInt32`
- `maxInt64`
- `minInt64`
Integer limit values.
## Functions
- `abs(x float) => float`: returns the absolute value of x.

View file

@ -7,17 +7,31 @@ import (
)
var mathModule = map[string]tengo.Object{
"e": &tengo.Float{Value: math.E},
"pi": &tengo.Float{Value: math.Pi},
"phi": &tengo.Float{Value: math.Phi},
"sqrt2": &tengo.Float{Value: math.Sqrt2},
"sqrtE": &tengo.Float{Value: math.SqrtE},
"sqrtPi": &tengo.Float{Value: math.SqrtPi},
"sqrtPhi": &tengo.Float{Value: math.SqrtPhi},
"ln2": &tengo.Float{Value: math.Ln2},
"log2E": &tengo.Float{Value: math.Log2E},
"ln10": &tengo.Float{Value: math.Ln10},
"log10E": &tengo.Float{Value: math.Log10E},
"e": &tengo.Float{Value: math.E},
"pi": &tengo.Float{Value: math.Pi},
"phi": &tengo.Float{Value: math.Phi},
"sqrt2": &tengo.Float{Value: math.Sqrt2},
"sqrtE": &tengo.Float{Value: math.SqrtE},
"sqrtPi": &tengo.Float{Value: math.SqrtPi},
"sqrtPhi": &tengo.Float{Value: math.SqrtPhi},
"ln2": &tengo.Float{Value: math.Ln2},
"log2E": &tengo.Float{Value: math.Log2E},
"ln10": &tengo.Float{Value: math.Ln10},
"log10E": &tengo.Float{Value: math.Log10E},
"maxFloat32": &tengo.Float{Value: math.MaxFloat32},
"smallestNonzeroFloat32": &tengo.Float{Value: math.SmallestNonzeroFloat32},
"maxFloat64": &tengo.Float{Value: math.MaxFloat64},
"smallestNonzeroFloat64": &tengo.Float{Value: math.SmallestNonzeroFloat64},
"maxInt": &tengo.Int{Value: math.MaxInt},
"minInt": &tengo.Int{Value: math.MinInt},
"maxInt8": &tengo.Int{Value: math.MaxInt8},
"minInt8": &tengo.Int{Value: math.MinInt8},
"maxInt16": &tengo.Int{Value: math.MaxInt16},
"minInt16": &tengo.Int{Value: math.MinInt16},
"maxInt32": &tengo.Int{Value: math.MaxInt32},
"minInt32": &tengo.Int{Value: math.MinInt32},
"maxInt64": &tengo.Int{Value: math.MaxInt64},
"minInt64": &tengo.Int{Value: math.MinInt64},
"abs": &tengo.UserFunction{
Name: "abs",
Value: FuncAFRF(math.Abs),