MCPcopy Create free account
hub / github.com/brimdata/super / compareNumbers

Function compareNumbers

runtime/sam/expr/eval.go:348–374  ·  view source on GitHub ↗
(a, b super.Value, aid, bid int)

Source from the content-addressed store, hash-verified

346}
347
348func compareNumbers(a, b super.Value, aid, bid int) int {
349 switch {
350 case super.IsFloat(aid):
351 return cmp.Compare(a.Float(), toFloat(b))
352 case super.IsFloat(bid):
353 return cmp.Compare(toFloat(a), b.Float())
354 case super.IsSigned(aid):
355 av := a.Int()
356 if super.IsUnsigned(bid) {
357 if av < 0 {
358 return -1
359 }
360 return cmp.Compare(uint64(av), b.Uint())
361 }
362 return cmp.Compare(av, b.Int())
363 case super.IsSigned(bid):
364 bv := b.Int()
365 if super.IsUnsigned(aid) {
366 if bv < 0 {
367 return 1
368 }
369 return cmp.Compare(a.Uint(), uint64(bv))
370 }
371 return cmp.Compare(a.Int(), bv)
372 }
373 return cmp.Compare(a.Uint(), b.Uint())
374}
375
376type isNullExpr struct {
377 eval Evaluator

Callers 2

compareValuesFunction · 0.85
EvalMethod · 0.85

Calls 8

IsFloatFunction · 0.92
IsSignedFunction · 0.92
IsUnsignedFunction · 0.92
toFloatFunction · 0.85
FloatMethod · 0.80
CompareMethod · 0.45
IntMethod · 0.45
UintMethod · 0.45

Tested by

no test coverage detected