🌐
W3Schools
w3schools.com › c › c_ref_math.php
C math (math.h) Library Reference
C Examples C Real-Life Examples C Exercises C Quiz C Code Challenges C Compiler C Syllabus C Study Plan C Interview Q&A C Certificate ... The <math.h> library has many functions that allow you to perform mathematical tasks on numbers.
C standard library header file providing mathematical functions
C mathematical operations are a group of functions in the standard library of the C programming language implementing basic mathematical functions. Different C standards provide different, albeit backwards-compatible, sets of functions. Most … Wikipedia
🌐
Wikipedia
en.wikipedia.org › wiki › C_mathematical_functions
C mathematical functions - Wikipedia
February 14, 2026 - C mathematical operations are a group of functions in the standard library of the C programming language implementing basic mathematical functions. Different C standards provide different, albeit backwards-compatible, sets of functions. Most of these functions are also available in the C++ ...
Discussions

compilation - Why do you have to link the math library in C? - Stack Overflow
If I include or in a C program, I don't have to link these when compiling, but I do have to link to , using -lm with GCC, for example: gcc test.c -o t... More on stackoverflow.com
🌐 stackoverflow.com
Open Source Mathematics Libraries
Intel's Math Kernel Library. More on reddit.com
🌐 r/C_Programming
9
12
January 19, 2020
All-Platform SIMD C Math Library
I hope the generated code is good. I've had very bad experiences with these portable SIMD frameworks before. More on reddit.com
🌐 r/C_Programming
13
49
December 20, 2022
MathC - a pure C math library for 2D and 3D programming
I saw similar stuff that use anonymous unions for the property names. This allows you to use the same struct in different contexts, as a quaternion, or a as color struct. Eg: struct i4 { union { int elem[4]; union { int x; int r; }; union { int y; int g; }; union { int z; int b; }; union { int w; int a; }; }; }; struct i4 m = {.0,.0,.0,.0}; m.elem[0] == m.x == m.r; m.elem[1] == m.y == m.g; A real world example you can see in the HandMade math library . More on reddit.com
🌐 r/C_Programming
26
52
October 5, 2017
🌐
TutorialsPoint
tutorialspoint.com › c_standard_library › math_h.htm
C Library - <math.h>
The math.h header defines various mathematical functions and one macro. All the functions available in this library take double as an argument and return double as the result. There is only one macro defined in this library − Following are the
Top answer
1 of 14
324

The functions in stdlib.h and stdio.h have implementations in libc.so (or libc.a for static linking), which is linked into your executable by default (as if -lc were specified). GCC can be instructed to avoid this automatic link with the -nostdlib or -nodefaultlibs options.

The math functions in math.h have implementations in libm.so (or libm.a for static linking), and libm is not linked in by default. There are historical reasons for this libm/libc split, none of them very convincing.

Interestingly, the C++ runtime libstdc++ requires libm, so if you compile a C++ program with GCC (g++), you will automatically get libm linked in.

2 of 14
104

Remember that C is an old language and that FPUs are a relatively recent phenomenon. I first saw C on 8-bit processors where it was a lot of work to do even 32-bit integer arithmetic. Many of these implementations didn't even have a floating point math library available!

Even on the first 68000 machines (Mac, Atari ST, Amiga), floating point coprocessors were often expensive add-ons.

To do all that floating point math, you needed a pretty sizable library. And the math was going to be slow. So you rarely used floats. You tried to do everything with integers or scaled integers. When you had to include math.h, you gritted your teeth. Often, you'd write your own approximations and lookup tables to avoid it.

Trade-offs existed for a long time. Sometimes there were competing math packages called "fastmath" or such. What's the best solution for math? Really accurate but slow stuff? Inaccurate but fast? Big tables for trig functions? It wasn't until coprocessors were guaranteed to be in the computer that most implementations became obvious. I imagine that there's some programmer out there somewhere right now, working on an embedded chip, trying to decide whether to bring in the math library to handle some math problem.

That's why math wasn't standard. Many or maybe most programs didn't use a single float. If FPUs had always been around and floats and doubles were always cheap to operate on, no doubt there would have been a "stdmath".

🌐
MIT
web.mit.edu › 10.001 › Web › Course_Notes › c_Notes › tips_math_library.html
Using the flag -lm (add math library)
There is a library of C functions called the "mathematics library" for performing many common math functions. There are functions such as sqrt, pow, sin, cos, sinh, tanh, etc. You can get a listing of the available functions by using the man command's '-k' option: ... To learn more about any ...
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-library-math_h
C Library - math.h - GeeksforGeeks
July 23, 2025 - The math.h library in C provides a set of functions for performing mathematical operations.
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-runtime-library › floating-point-support
Math and floating-point support | Microsoft Learn
April 21, 2025 - The Universal C Runtime library (UCRT) provides many integral and floating-point math library functions, including all of the functions required by ISO C99. The floating-point functions are implemented to balance performance with correctness.
Find elsewhere
🌐
Reddit
reddit.com › r/c_programming › open source mathematics libraries
r/C_Programming on Reddit: Open Source Mathematics Libraries
January 19, 2020 -

What are some comprehensive math libraries for C? Specifically for using linear algebra, calculus, probability, and statistics? I want to practice deep learning algorithms but don't want to dig down so low as to implement all of the underlying math as well.

🌐
LabEx
labex.io › tutorials › c-how-to-link-math-library-in-c-compilation-419183
How to link math library in C compilation | LabEx
These functions are crucial for ... library in C, typically represented by <math.h>, offers a comprehensive set of mathematical functions for various computational needs....
🌐
GNU
gnu.org › software › libc › manual › html_node › Mathematics.html
Mathematics (The GNU C Library)
This chapter contains information about functions for performing mathematical computations, such as trigonometric functions. Most of these functions have prototypes declared in the header file math.h.
🌐
Wikibooks
en.wikibooks.org › wiki › C_Programming › math.h
C Programming/math.h - Wikibooks, open books for an open world
February 20, 2006 - math.h is a header file in the standard library of the C programming language designed for basic mathematical operations. Most of the functions involve the use of floating point numbers.
🌐
cppreference.com
en.cppreference.com › w › c › header › math.html
Standard library header <math.h>
February 3, 2025 - Log in · Page · Discussion · View · Edit · History · From cppreference.com · < c‎ | header · C · [edit] Standard Library headers · [edit] This header is part of the mathematics library. #define __STDC_VERSION_MATH_H__ 202311L // TODO: ... Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/header/math&oldid=180107" Category: Todo with reason ·
🌐
W3Schools
w3schools.com › c › c_math.php
C Math Functions
The ceil() function rounds a number upwards to its nearest integer, and the floor() method rounds a number downwards to its nearest integer, and returns the result: printf("%f", ceil(1.4)); printf("%f", floor(1.4)); Try it Yourself » · The pow() function returns the value of x to the power of y (xy): ... For a complete reference of math functions, go to our C <math.h> Library Reference.
🌐
Llvm
libc.llvm.org › math
math.h - LLVM C Library
LLVM-libc is a from-scratch implementation of the C standard library, built as part of the LLVM project. It is designed to be modular (any piece can be used independently), multiplatform (Linux, GPU, baremetal embedded, UEFI, macOS, Windows), and written in modern C++ for correctness, performance, ...
🌐
GitHub
github.com › felselva › mathc
GitHub - felselva/mathc: Pure C math library for 2D and 3D programming · GitHub
Pure C math library for 2D and 3D programming. Contribute to felselva/mathc development by creating an account on GitHub.
Starred by 760 users
Forked by 60 users
Languages   C
🌐
Programiz
programiz.com › c-programming › library-function › math.h
C math.h
The C <math.h> header file declares a set of functions to perform mathematical operations such as: sqrt() to calculate the square root, log() to find natural logarithm of a number etc.
🌐
Reddit
reddit.com › r/c_programming › all-platform simd c math library
r/C_Programming on Reddit: All-Platform SIMD C Math Library
December 20, 2022 -

Hi C friends,

I wanted to share with you my math library that I use for my game engine. It's a highly optimized, single-header 3D math library written in C that uses SIMDE as the back-end. This means that if a platform supports vector registers, then the compiler will do a very good job of auto-vectorizing the code. Currently tested on: x86-64, ARM64, RISC-V, PowerPC, MIPS, SPARC, and KVX.

Contains the standard types and functions needed for 3D graphics.

Tested with Clang, GCC, MSVC.

This type of library is usually only done for x86, and maybe sometimes for ARM, but this allows you to compile the same SIMD-optimized code for any platform. If the platform doesn't have vector registers, then the compiler will treat it as scalar code and optimize it accordingly.

It also optionally uses SLEEF, so if you have that installed on your system, simply uncomment "sleef.h" at the top of the file and you'll be able to use vectorized math.h functions. If you don't have SLEEF, then the compiler will do it's best to vectorize this code, or if you have a recent Intel CPU, it will call SVML elementary functions.

To use, just clone SIMDE into the same folder as cml.h.

https://github.com/pbotmeyertron/c_math_library

🌐
GitHub
github.com › ScientificC › cmathl
GitHub - ScientificC/cmathl: A pure-C math library with a great variety of mathematical functions. Seeks to be close to C89/C90 compliant for portability. · GitHub
A pure-C math library with a great variety of mathematical functions. Seeks to be close to C89/C90 compliant for portability. - ScientificC/cmathl
Starred by 58 users
Forked by 9 users
Languages   C 65.9% | Perl 31.4% | CMake 2.0%
🌐
Medium
medium.com › @Dev_Frank › math-functions-in-c-16248fe98ae8
MATH FUNCTIONS IN C. When working with numbers in C, have… | by Dev Frank | Medium
April 21, 2024 - Mathematical operations are an essential part of programming, and C, being a general-purpose programming language, provides a robust set of math functions to perform various calculations. In fact, did you know that the C standard library provides ...