Copyright The OpenTelemetry Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

package metric
go:generate stringer -type=NumberKind

import (
	
	
	

	
)
NumberKind describes the data type of the Number.
Int64NumberKind means that the Number stores int64.
Float64NumberKind means that the Number stores float64.
Zero returns a zero value for a given NumberKind
func ( NumberKind) () Number {
	switch  {
	case Int64NumberKind:
		return NewInt64Number(0)
	case Float64NumberKind:
		return NewFloat64Number(0.)
	default:
		return Number(0)
	}
}
Minimum returns the minimum representable value for a given NumberKind
func ( NumberKind) () Number {
	switch  {
	case Int64NumberKind:
		return NewInt64Number(math.MinInt64)
	case Float64NumberKind:
		return NewFloat64Number(-1. * math.MaxFloat64)
	default:
		return Number(0)
	}
}
Maximum returns the maximum representable value for a given NumberKind
func ( NumberKind) () Number {
	switch  {
	case Int64NumberKind:
		return NewInt64Number(math.MaxInt64)
	case Float64NumberKind:
		return NewFloat64Number(math.MaxFloat64)
	default:
		return Number(0)
	}
}
Number represents either an integral or a floating point value. It needs to be accompanied with a source of NumberKind that describes the actual type of the value stored within Number.
- constructors
NewNumberFromRaw creates a new Number from a raw value.
func ( uint64) Number {
	return Number()
}
NewInt64Number creates an integral Number.
NewFloat64Number creates a floating point Number.
NewNumberSignChange returns a number with the same magnitude and the opposite sign. `kind` must describe the kind of number in `nn`. Does not change Uint64NumberKind values.
func ( NumberKind,  Number) Number {
	switch  {
	case Int64NumberKind:
		return NewInt64Number(-.AsInt64())
	case Float64NumberKind:
		return NewFloat64Number(-.AsFloat64())
	}
	return 
}
- as x
AsNumber gets the Number.
func ( *Number) () Number {
	return *
}
AsRaw gets the uninterpreted raw value. Might be useful for some atomic operations.
func ( *Number) () uint64 {
	return uint64(*)
}
AsInt64 assumes that the value contains an int64 and returns it as such.
func ( *Number) () int64 {
	return internal.RawToInt64(.AsRaw())
}
AsFloat64 assumes that the measurement value contains a float64 and returns it as such.
func ( *Number) () float64 {
	return internal.RawToFloat64(.AsRaw())
}
- as x atomic
AsNumberAtomic gets the Number atomically.
AsRawAtomic gets the uninterpreted raw value atomically. Might be useful for some atomic operations.
func ( *Number) () uint64 {
	return atomic.LoadUint64(.AsRawPtr())
}
AsInt64Atomic assumes that the number contains an int64 and returns it as such atomically.
func ( *Number) () int64 {
	return atomic.LoadInt64(.AsInt64Ptr())
}
AsFloat64Atomic assumes that the measurement value contains a float64 and returns it as such atomically.
- as x ptr
AsRawPtr gets the pointer to the raw, uninterpreted raw value. Might be useful for some atomic operations.
func ( *Number) () *uint64 {
	return (*uint64)()
}
AsInt64Ptr assumes that the number contains an int64 and returns a pointer to it.
AsFloat64Ptr assumes that the number contains a float64 and returns a pointer to it.
- coerce
CoerceToInt64 casts the number to int64. May result in data/precision loss.
func ( *Number) ( NumberKind) int64 {
	switch  {
	case Int64NumberKind:
		return .AsInt64()
	case Float64NumberKind:
		return int64(.AsFloat64())
you get what you deserve
		return 0
	}
}
CoerceToFloat64 casts the number to float64. May result in data/precision loss.
func ( *Number) ( NumberKind) float64 {
	switch  {
	case Int64NumberKind:
		return float64(.AsInt64())
	case Float64NumberKind:
		return .AsFloat64()
you get what you deserve
		return 0
	}
}
- set
SetNumber sets the number to the passed number. Both should be of the same kind.
func ( *Number) ( Number) {
	*.AsRawPtr() = .AsRaw()
}
SetRaw sets the number to the passed raw value. Both number and the raw number should represent the same kind.
func ( *Number) ( uint64) {
	*.AsRawPtr() = 
}
SetInt64 assumes that the number contains an int64 and sets it to the passed value.
func ( *Number) ( int64) {
	*.AsInt64Ptr() = 
}
SetFloat64 assumes that the number contains a float64 and sets it to the passed value.
func ( *Number) ( float64) {
	*.AsFloat64Ptr() = 
}
- set atomic
SetNumberAtomic sets the number to the passed number atomically. Both should be of the same kind.
SetRawAtomic sets the number to the passed raw value atomically. Both number and the raw number should represent the same kind.
SetInt64Atomic assumes that the number contains an int64 and sets it to the passed value atomically.
SetFloat64Atomic assumes that the number contains a float64 and sets it to the passed value atomically.
- swap
SwapNumber sets the number to the passed number and returns the old number. Both this number and the passed number should be of the same kind.
func ( *Number) ( Number) Number {
	 := *
	.SetNumber()
	return 
}
SwapRaw sets the number to the passed raw value and returns the old raw value. Both number and the raw number should represent the same kind.
func ( *Number) ( uint64) uint64 {
	 := .AsRaw()
	.SetRaw()
	return 
}
SwapInt64 assumes that the number contains an int64, sets it to the passed value and returns the old int64 value.
func ( *Number) ( int64) int64 {
	 := .AsInt64()
	.SetInt64()
	return 
}
SwapFloat64 assumes that the number contains an float64, sets it to the passed value and returns the old float64 value.
func ( *Number) ( float64) float64 {
	 := .AsFloat64()
	.SetFloat64()
	return 
}
- swap atomic
SwapNumberAtomic sets the number to the passed number and returns the old number atomically. Both this number and the passed number should be of the same kind.
SwapRawAtomic sets the number to the passed raw value and returns the old raw value atomically. Both number and the raw number should represent the same kind.
func ( *Number) ( uint64) uint64 {
	return atomic.SwapUint64(.AsRawPtr(), )
}
SwapInt64Atomic assumes that the number contains an int64, sets it to the passed value and returns the old int64 value atomically.
func ( *Number) ( int64) int64 {
	return atomic.SwapInt64(.AsInt64Ptr(), )
}
SwapFloat64Atomic assumes that the number contains an float64, sets it to the passed value and returns the old float64 value atomically.
- add
AddNumber assumes that this and the passed number are of the passed kind and adds the passed number to this number.
func ( *Number) ( NumberKind,  Number) {
	switch  {
	case Int64NumberKind:
		.AddInt64(.AsInt64())
	case Float64NumberKind:
		.AddFloat64(.AsFloat64())
	}
}
AddRaw assumes that this number and the passed raw value are of the passed kind and adds the passed raw value to this number.
func ( *Number) ( NumberKind,  uint64) {
	.AddNumber(, NewNumberFromRaw())
}
AddInt64 assumes that the number contains an int64 and adds the passed int64 to it.
func ( *Number) ( int64) {
	*.AsInt64Ptr() += 
}
AddFloat64 assumes that the number contains a float64 and adds the passed float64 to it.
func ( *Number) ( float64) {
	*.AsFloat64Ptr() += 
}
- add atomic
AddNumberAtomic assumes that this and the passed number are of the passed kind and adds the passed number to this number atomically.
func ( *Number) ( NumberKind,  Number) {
	switch  {
	case Int64NumberKind:
		.AddInt64Atomic(.AsInt64())
	case Float64NumberKind:
		.AddFloat64Atomic(.AsFloat64())
	}
}
AddRawAtomic assumes that this number and the passed raw value are of the passed kind and adds the passed raw value to this number atomically.
AddInt64Atomic assumes that the number contains an int64 and adds the passed int64 to it atomically.
AddFloat64Atomic assumes that the number contains a float64 and adds the passed float64 to it atomically.
func ( *Number) ( float64) {
	for {
		 := .AsFloat64Atomic()
		if .CompareAndSwapFloat64(, +) {
			break
		}
	}
}
- compare and swap (atomic only)
CompareAndSwapNumber does the atomic CAS operation on this number. This number and passed old and new numbers should be of the same kind.
func ( *Number) (,  Number) bool {
	return atomic.CompareAndSwapUint64(.AsRawPtr(), .AsRaw(), .AsRaw())
}
CompareAndSwapRaw does the atomic CAS operation on this number. This number and passed old and new raw values should be of the same kind.
func ( *Number) (,  uint64) bool {
	return atomic.CompareAndSwapUint64(.AsRawPtr(), , )
}
CompareAndSwapInt64 assumes that this number contains an int64 and does the atomic CAS operation on it.
func ( *Number) (,  int64) bool {
	return atomic.CompareAndSwapInt64(.AsInt64Ptr(), , )
}
CompareAndSwapFloat64 assumes that this number contains a float64 and does the atomic CAS operation on it.
- compare
CompareNumber compares two Numbers given their kind. Both numbers should have the same kind. This returns: 0 if the numbers are equal -1 if the subject `n` is less than the argument `nn` +1 if the subject `n` is greater than the argument `nn`
func ( *Number) ( NumberKind,  Number) int {
	switch  {
	case Int64NumberKind:
		return .CompareInt64(.AsInt64())
	case Float64NumberKind:
		return .CompareFloat64(.AsFloat64())
you get what you deserve
		return 0
	}
}
CompareRaw compares two numbers, where one is input as a raw uint64, interpreting both values as a `kind` of number.
func ( *Number) ( NumberKind,  uint64) int {
	return .CompareNumber(, NewNumberFromRaw())
}
CompareInt64 assumes that the Number contains an int64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other.
func ( *Number) ( int64) int {
	 := .AsInt64()
	if  <  {
		return -1
	} else if  >  {
		return 1
	}
	return 0
}
CompareFloat64 assumes that the Number contains a float64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other. Do not compare NaN values.
func ( *Number) ( float64) int {
	 := .AsFloat64()
	if  <  {
		return -1
	} else if  >  {
		return 1
	}
	return 0
}
- relations to zero
IsPositive returns true if the actual value is greater than zero.
func ( *Number) ( NumberKind) bool {
	return .compareWithZero() > 0
}
IsNegative returns true if the actual value is less than zero.
func ( *Number) ( NumberKind) bool {
	return .compareWithZero() < 0
}
IsZero returns true if the actual value is equal to zero.
func ( *Number) ( NumberKind) bool {
	return .compareWithZero() == 0
}
- misc
Emit returns a string representation of the raw value of the Number. A %d is used for integral values, %f for floating point values.
func ( *Number) ( NumberKind) string {
	switch  {
	case Int64NumberKind:
		return fmt.Sprintf("%d", .AsInt64())
	case Float64NumberKind:
		return fmt.Sprintf("%f", .AsFloat64())
	default:
		return ""
	}
}
AsInterface returns the number as an interface{}, typically used for NumberKind-correct JSON conversion.
func ( *Number) ( NumberKind) interface{} {
	switch  {
	case Int64NumberKind:
		return .AsInt64()
	case Float64NumberKind:
		return .AsFloat64()
	default:
		return math.NaN()
	}
}
- private stuff

func ( *Number) ( NumberKind) int {
	switch  {
	case Int64NumberKind:
		return .CompareInt64(0)
	case Float64NumberKind:
		return .CompareFloat64(0.)
you get what you deserve
		return 0
	}