github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/math/degrees.go (about) 1 package math 2 3 import ( 4 "context" 5 6 "github.com/MontFerret/ferret/pkg/runtime/core" 7 "github.com/MontFerret/ferret/pkg/runtime/values" 8 "github.com/MontFerret/ferret/pkg/runtime/values/types" 9 ) 10 11 // DEGREES returns the angle converted from radians to degrees. 12 // @param {Int | Float} number - The input number. 13 // @return {Float} - The angle in degrees 14 func Degrees(_ context.Context, args ...core.Value) (core.Value, error) { 15 err := core.ValidateArgs(args, 1, 1) 16 17 if err != nil { 18 return values.None, err 19 } 20 21 err = core.ValidateType(args[0], types.Int, types.Float) 22 23 if err != nil { 24 return values.None, err 25 } 26 27 r := toFloat(args[0]) 28 29 return values.NewFloat(r * RadToDeg), nil 30 }