{"version":3,"file":"util.cjs","names":[],"sources":["../../../src/aggregator/exponential-histogram/util.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Note: other languages provide this as a built in function. This is\n * a naive, but functionally correct implementation. This is used sparingly,\n * when creating a new mapping in a running application.\n *\n * ldexp returns frac × 2**exp. With the following special cases:\n *   ldexp(±0, exp) = ±0\n *   ldexp(±Inf, exp) = ±Inf\n *   ldexp(NaN, exp) = NaN\n * @param frac\n * @param exp\n * @returns {number}\n */\nexport function ldexp(frac: number, exp: number): number {\n  if (\n    frac === 0 ||\n    frac === Number.POSITIVE_INFINITY ||\n    frac === Number.NEGATIVE_INFINITY ||\n    Number.isNaN(frac)\n  ) {\n    return frac;\n  }\n  return frac * Math.pow(2, exp);\n}\n\n/**\n * Computes the next power of two that is greater than or equal to v.\n * This implementation more efficient than, but functionally equivalent\n * to Math.pow(2, Math.ceil(Math.log(x)/Math.log(2))).\n * @param v\n * @returns {number}\n */\nexport function nextGreaterSquare(v: number): number {\n  // The following expression computes the least power-of-two\n  // that is >= v.  There are a number of tricky ways to\n  // do this, see https://stackoverflow.com/questions/466204/rounding-up-to-next-power-of-2\n  v--;\n  v |= v >> 1;\n  v |= v >> 2;\n  v |= v >> 4;\n  v |= v >> 8;\n  v |= v >> 16;\n  v++;\n  return v;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,MAAM,MAAc,KAAqB;CACvD,IACE,SAAS,KACT,SAAS,OAAO,qBAChB,SAAS,OAAO,qBAChB,OAAO,MAAM,IAAI,GAEjB,OAAO;CAET,OAAO,OAAO,KAAK,IAAI,GAAG,GAAG;AAC/B;;;;;;;;AASA,SAAgB,kBAAkB,GAAmB;CAInD;CACA,KAAK,KAAK;CACV,KAAK,KAAK;CACV,KAAK,KAAK;CACV,KAAK,KAAK;CACV,KAAK,KAAK;CACV;CACA,OAAO;AACT"}