log2(3)
β¨ log2(3) β¨
okay so bestie, welcome to the log2 page of the Linux man-pages (that's the Library Functions Manual btw π). this is the lowdown on the base-2 logarithm crew and honestly? they ate. let's get into it π
πΈ NAME πΈ
log2, log2f, log2l β the base-2 logarithmic function, aka the whole girl group π
π LIBRARY π
the Math library β link it with libm, so like -lm when you're compiling. don't forget it or she will NOT show up. periodt π
π¦ SYNOPSIS π¦
#include <math.h>
double log2(double x);
float log2f(float x);
long double log2l(long double x);
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)): π
log2(), log2f(), log2l():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
no cap, you gotta have one of those defined or glibc's like "who r u" π
π DESCRIPTION π
these functions return the base-2 logarithm of x. that's the whole personality trait. simple, iconic, no notes β¨
π RETURN VALUE π
on success, these functions return the base-2 logarithm of x. slay.
for special cases β and bestie that includes when x is 0, 1, negative, infinity, or NaN β you gotta go see log(3). she's got the tea β
π ERRORS π
peep math_error(7) for the info on how to figure out whether an error has even occurred when you call these functions. detection era π
and for the full discussion of the errors that can occur for these functions? yeah, again, go read log(3). she spilled first π
π§ ATTRIBUTES π§
for an explanation of the terms used in this section, see attributes(7).
log2(),log2f(),log2l()β Thread safety: MT-Safe π«Ά
(that's the whole table bestie, just the one row, and she's MT-Safe so you can vibe in multiple threads no problem π)
π STANDARDS π
C11, POSIX.1-2008. certified, official, main character energy π
π HISTORY π
glibc 2.1. C99, POSIX.1-2001. look at her, ancient icon, still serving π
the variant returning double also conforms to SVr4 and 4.3BSD. so she's versatile too?? obsessed π₯
π SEE ALSO π
ngl if you're out here passing a negative or a zero to these, that's undefined-ish behaviour territory β go read log(3) before you're shocked pikachu π the whole special-case saga lives there.
and that's the page bestie!! this came straight from Linux man-pages 6.20, dated 2026-02-08, all about our girl log2(3). go forth and compute some base-2 logs, you absolute icon π«Άβ¨π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms