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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms