KCC - Kayte C Compiler 1.10.0
A C compiler implementation with preprocessor, lexer, parser, and code generator
Loading...
Searching...
No Matches
math.h
1//
2// Created by Pedro Dias Vicente on 03/09/2025.
3//
4/*
5 * simple_math.h - A simplified, educational example of what the
6 * C standard math header (math.h) might look like.
7 *
8 * This file demonstrates function prototypes and macros for common
9 * mathematical operations.
10 */
11
12// =============================================================================
13// 1. Header Guard
14// =============================================================================
15#ifndef MATH_H
16#define MATH_H
17
18// =============================================================================
19// 2. Macro Definitions for Mathematical Constants
20// =============================================================================
21#define M_PI 3.14159265358979323846 // Pi
22#define M_E 2.71828182845904523536 // Euler's number
23#define M_SQRT2 1.41421356237309504880 // Square root of 2
24
25// =============================================================================
26// 3. Function Prototypes (Declarations)
27// =============================================================================
28// These functions typically operate on 'double' precision floating-point numbers.
29// The actual implementations are in the C standard library.
30
31// --- Trigonometric Functions ---
32// Note: These functions usually take angles in radians.
33double sin(double x); // Sine of x
34double cos(double x); // Cosine of x
35double tan(double x); // Tangent of x
36
37// --- Inverse Trigonometric Functions ---
38double asin(double x); // Arc sine of x
39double acos(double x); // Arc cosine of x
40double atan(double x); // Arc tangent of x
41
42// --- Hyperbolic Functions ---
43double sinh(double x); // Hyperbolic sine of x
44double cosh(double x); // Hyperbolic cosine of x
45double tanh(double x); // Hyperbolic tangent of x
46
47// --- Exponential and Logarithmic Functions ---
48double exp(double x); // Returns e raised to the power of x
49double log(double x); // Natural logarithm (base e)
50double log10(double x); // Common logarithm (base 10)
51
52// --- Power Functions ---
53double pow(double base, double exponent); // base raised to the power of exponent
54double sqrt(double x); // Square root of x
55
56// --- Rounding and Remainder Functions ---
57double ceil(double x); // Smallest integer value not less than x
58double floor(double x); // Largest integer value not greater than x
59double fabs(double x); // Absolute value of x
60double fmod(double x, double y); // Floating-point remainder of x/y
61
62int sum(int a, int b);
63int div(int a, int b);
64int mod(int a, int b);
65int abs(int a);
66int min(int a, int b);
67int max(int a, int b);
68
69#endif // End of header guard MATH_H