ILOG2(3)
β¨ ILOG2(3) β ilog2, the integer base-2 logarithm β¨
okay bestie, welcome to ILOG2(3) π this one is short, iconic, and lowkey doing math at the club. it's the ilog2 manual page, and we're gonna get through it together, no cap.
π NAME π
ilog2 β integer base-2 logarithm π
πΈ SYNOPSIS πΈ
#include <sys/bitops.h>
int
ilog2(size x);
literally the whole vibe right there, bestie π«Ά
π¦ DESCRIPTION π¦
okay so for positive x, the ilog2() macro returns the integer part of the base-2 logarithm of x β that is, floor(log_2(x) ). slay. π₯
if n = ilog2(x), then n is the largest integer such that 2**n <= x. in other words: ilog2() returns the largest integer to which 2 can be raised to obtain a value at most x. that's the whole plot, and it ate π
the type of the input parameter must be unsigned. not me being strict, that's just the rule, bestie π
if x is a constant expression, then so is ilog2(x). constant-expression main character energy, periodt β¨
π ERRORS π
ilog2() returns -1 when x is zero. yes, zero gets the -1, no cap π
bestie please notice this: zero does not get a cute little logarithm moment. it gets -1. that's the error behavior and we respect it π
π SEE ALSO π
go read those too, iykyk π§π
π HISTORY π
the ilog2() macro first appeared in NetBSD 5.0. vintage-ish, but make it fashion π
β
and that's the page, bestie π this cutie is from Debian, dated November 5, 2021 β mwah ππ«Ά
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms