diff --git a/docs/stdlib-math.md b/docs/stdlib-math.md index d68eb777..ce8d2cdd 100644 --- a/docs/stdlib-math.md +++ b/docs/stdlib-math.md @@ -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. diff --git a/stdlib/math.go b/stdlib/math.go index 633ea09f..1bd9ba69 100644 --- a/stdlib/math.go +++ b/stdlib/math.go @@ -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),