// 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 internal // import "github.com/lightstep/go-expohisto/mapping/internal" import "math" const ( // SignificandWidth is the size of an IEEE 754 double-precision // floating-point significand. SignificandWidth = 52 // ExponentWidth is the size of an IEEE 754 double-precision // floating-point exponent. ExponentWidth = 11 // SignificandMask is the mask for the significand of an IEEE 754 // double-precision floating-point value: 0xFFFFFFFFFFFFF. SignificandMask = 1<> SignificandWidth return int32(rawExponent - ExponentBias) } // GetSignificand returns the 52 bit (unsigned) significand as a // signed value. func GetSignificand(value float64) int64 { return int64(math.Float64bits(value)) & SignificandMask }