(n: number): numberReturns the next power of 2 from the given number.
When to use
Use to round a number up to the next power of two.
Example (Finding the next power of two)
import { Number } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Number.nextPow2(5), 8)
assert.deepStrictEqual(Number.nextPow2(17), 32)export const const nextPow2: (n: number) => numberReturns the next power of 2 from the given number.
When to use
Use to round a number up to the next power of two.
Example (Finding the next power of two)
import { Number } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Number.nextPow2(5), 8)
assert.deepStrictEqual(Number.nextPow2(17), 32)
nextPow2 = (n: numbern: number): number => {
const const nextPow: numbernextPow = var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.ceil(x: number): numberReturns the smallest integer greater than or equal to its numeric argument.
ceil(var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.log(x: number): numberReturns the natural logarithm (base e) of a number.
log(n: numbern) / var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.log(x: number): numberReturns the natural logarithm (base e) of a number.
log(2))
return var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.max(...values: number[]): numberReturns the larger of a set of supplied numeric expressions.
max(var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.pow(x: number, y: number): numberReturns the value of a base expression taken to a specified power.
pow(2, const nextPow: numbernextPow), 2)
}