Every line of 'golang absolute value' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
356 func Abs8(val int8) int8 { 357 if val < 0 { 358 return val * -1 359 } 360 361 return val 362 }
27 func Absi64(a int64) int64 { 28 if a > 0 { 29 return a 30 } else { 31 return -a 32 } 33 }
202 func (gd *GaugeDiff) UpdateAbsolute(absolute int64) int64 { 203 gd.Mutex.Lock() 204 defer gd.Mutex.Unlock() 205 previous := gd.Previous.Snapshot().Value() 206 gd.Absolute.Update(absolute) 207 gd.Previous.Update(absolute) 208 if previous == 0 { // no previous value, cannot calc absolute delta 209 return 0 210 } 211 if absolute < previous { // counters got reset, gonna update with absolute value 212 previous = 0 213 } 214 delta := absolute - previous 215 gd.Delta.Update(delta) 216 return delta 217 }
33 func Abs(f *Frame, o *Object) (*Object, *BaseException) { 34 abs := o.typ.slots.Abs 35 if abs == nil { 36 return nil, f.RaiseType(TypeErrorType, fmt.Sprintf("bad operand type for abs(): '%s'", o.typ.Name())) 37 } 38 return abs.Fn(f, o) 39 }
114 func (a offsetAnchor) value(sys *Layouter) float64 { 115 return a.underlying.value(sys) + a.offset 116 }
27 func AbsInt(x int) int { 28 if x >= 0 { 29 return x 30 } 31 if x == minInt { 32 // this case must not happen 33 panic("absolute overflows int") 34 } 35 return -x 36 }
33 func Abs(value *big.Int) *big.Int { 34 ret := Clone(value) 35 return ret.Neg(value) 36 }