MCPcopy Create free account
hub / github.com/cel-expr/cel-go / sign

Function sign

ext/math.go:713–737  ·  view source on GitHub ↗
(val ref.Val)

Source from the content-addressed store, hash-verified

711}
712
713func sign(val ref.Val) ref.Val {
714 switch v := val.(type) {
715 case types.Double:
716 if isNaN(v) == types.True {
717 return v
718 }
719 zero := types.Double(0)
720 if v > zero {
721 return types.Double(1)
722 }
723 if v < zero {
724 return types.Double(-1)
725 }
726 return zero
727 case types.Int:
728 return v.Compare(types.IntZero)
729 case types.Uint:
730 if v == types.Uint(0) {
731 return types.Uint(0)
732 }
733 return types.Uint(1)
734 default:
735 return maybeSuffixError(val, "math.sign")
736 }
737}
738
739func sqrt(val ref.Val) ref.Val {
740 switch v := val.(type) {

Callers

nothing calls this directly

Calls 5

DoubleTypeAlias · 0.92
UintTypeAlias · 0.92
maybeSuffixErrorFunction · 0.85
isNaNFunction · 0.70
CompareMethod · 0.65

Tested by

no test coverage detected